From 2fd50b104c9431a603310800b9ee4d0d44ce9391 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 31 Oct 2023 12:16:26 -0700 Subject: [PATCH] check hooks are enabled before firing --- controller/PostgreSQL.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index fd99e0ff2..0ab721dcd 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -1436,7 +1436,21 @@ void PostgreSQL::commitThread() w.commit(); if (_smee != NULL && isNewMember) { - notifyNewMember(networkId, memberId); + pqxx::row row = w.exec_params1( + "SELECT " + " count(h.hook_id) " + "FROM " + " ztc_hook h " + " INNER JOIN ztc_org o ON o.org_id = h.org_id " + " INNER JOIN ztc_network n ON n.owner_id = o.owner_id " + " WHERE " + "n.id = $1 ", + networkId + ); + int64_t hookCount = row[0].as(); + if (hookCount > 0) { + notifyNewMember(networkId, memberId); + } } const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL);