summaryrefslogtreecommitdiff
path: root/controller
diff options
context:
space:
mode:
authorGrant Limberg <[email protected]>2023-10-31 12:16:26 -0700
committerGrant Limberg <[email protected]>2023-10-31 12:16:26 -0700
commit2fd50b104c9431a603310800b9ee4d0d44ce9391 (patch)
treebb6a16e52afde3af9aaa1a826a0cfdefb385d6f2 /controller
parent0088cef2fc6d68de9d6938f1da9f1452827e6bbe (diff)
check hooks are enabled before firing
Diffstat (limited to 'controller')
-rw-r--r--controller/PostgreSQL.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp
index fd99e0ff..0ab721dc 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<int64_t>();
+ if (hookCount > 0) {
+ notifyNewMember(networkId, memberId);
+ }
}
const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL);