diff options
| author | Grant Limberg <[email protected]> | 2023-08-30 14:51:39 -0700 |
|---|---|---|
| committer | Grant Limberg <[email protected]> | 2023-08-30 14:51:39 -0700 |
| commit | d322f332e8301d0a65202d429f7062f999a2a2d2 (patch) | |
| tree | 93d93caaef92ee310032b72da262c56ec9861e64 /controller/PostgreSQL.cpp | |
| parent | 60fb8c941af3a01b074dc769d6d1a331421b5f36 (diff) | |
simplify hook firing
only need network and member IDs
Diffstat (limited to 'controller/PostgreSQL.cpp')
| -rw-r--r-- | controller/PostgreSQL.cpp | 46 |
1 files changed, 4 insertions, 42 deletions
diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index beee5e06..b1682e7e 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -1690,48 +1690,10 @@ void PostgreSQL::commitThread() } void PostgreSQL::notifyNewMember(const std::string &networkID, const std::string &memberID) { - std::shared_ptr<PostgresConnection> c; - try { - c = _pool->borrow(); - } catch (std::exception &e) { - fprintf(stderr, "ERROR: %s\n", e.what()); - return; - } - - try { - pqxx::work w(*c->c); - - // TODO: Add check for active subscription - - auto res = w.exec_params("SELECT h.hook_id " - "FROM ztc_hook h " - "INNER JOIN ztc_hook_hook_types ht " - "ON ht.hook_id = h.hook_id " - "INNER JOIN ztc_org o " - "ON o.org_id = h.org_id " - "INNER JOIN ztc_user u " - "ON u.id = o.owner_id " - "INNER JOIN ztc_network n " - "ON n.owner_id = u.id " - "WHERE n.id = $1 " - "AND ht.hook_type = 'NETWORK_JOIN'", networkID); - - for (auto const &row: res) { - std::string hookURL = row[0].as<std::string>(); - smeeclient::smee_client_notify_network_joined( - _smee, - networkID.c_str(), - memberID.c_str(), - hookURL.c_str(), - NULL - ); - } - - _pool->unborrow(c); - } catch (std::exception &e) { - fprintf(stderr, "ERROR: %s\n", e.what()); - return; - } + smeeclient::smee_client_notify_network_joined( + _smee, + networkID.c_str(), + memberID.c_str()); } void PostgreSQL::onlineNotificationThread() |
