diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index beee5e06d..b1682e7e0 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 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(); - 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() diff --git a/rustybits/smeeclient/src/ext.rs b/rustybits/smeeclient/src/ext.rs index 028635b80..f0d5c0d99 100644 --- a/rustybits/smeeclient/src/ext.rs +++ b/rustybits/smeeclient/src/ext.rs @@ -64,8 +64,6 @@ pub extern "C" fn smee_client_notify_network_joined( smee_instance: *mut SmeeClient, network_id: *const c_char, member_id: *const c_char, - hook_id: *const c_char, - src_ip: *const c_char, ) -> bool { let nwid = unsafe { assert!(!network_id.is_null()); @@ -77,25 +75,12 @@ pub extern "C" fn smee_client_notify_network_joined( CStr::from_ptr(member_id).to_str().unwrap() }; - let hid = unsafe { - assert!(!hook_id.is_null()); - CStr::from_ptr(hook_id).to_str().unwrap() - }; - - let src = unsafe { - if src_ip.is_null() { - None - } else { - Some(CStr::from_ptr(src_ip).to_str().unwrap()) - } - }; - let smee = unsafe { assert!(!smee_instance.is_null()); &mut *smee_instance }; - let params = NetworkJoinedParams::new(nwid, mem_id, hid, src); + let params = NetworkJoinedParams::new(nwid, mem_id); match smee.notify_network_joined(params) { Ok(()) => true, diff --git a/rustybits/smeeclient/src/lib.rs b/rustybits/smeeclient/src/lib.rs index 328024a51..af0f18d3e 100644 --- a/rustybits/smeeclient/src/lib.rs +++ b/rustybits/smeeclient/src/lib.rs @@ -31,24 +31,13 @@ pub struct NetworkJoinedParams { #[serde(rename = "MemberID")] pub member_id: String, - - #[serde(rename = "HookID")] - pub hook_id: String, - - #[serde(rename = "SrcIP")] - pub src_ip: Option, } impl NetworkJoinedParams { - fn new(network_id: &str, member_id: &str, hook_id: &str, src_ip: Option<&str>) -> Self { + fn new(network_id: &str, member_id: &str) -> Self { Self { network_id: network_id.to_string(), member_id: member_id.to_string(), - hook_id: hook_id.to_string(), - src_ip: match src_ip { - Some(x) => Some(x.to_string()), - None => None, - }, } } }