pass hook_id instead of url

This commit is contained in:
Grant Limberg 2023-08-15 14:51:14 -07:00
parent 714ef59814
commit 5becb41bd4
No known key found for this signature in database
GPG Key ID: 8F2F97D3BE8D7735
3 changed files with 10 additions and 12 deletions

View File

@ -1672,8 +1672,6 @@ void PostgreSQL::commitThread()
}
void PostgreSQL::notifyNewMember(const std::string &networkID, const std::string &memberID) {
// TODO: Look up hook URL for network owner organization
std::shared_ptr<PostgresConnection> c;
try {
c = _pool->borrow();
@ -1687,7 +1685,7 @@ void PostgreSQL::notifyNewMember(const std::string &networkID, const std::string
// TODO: Add check for active subscription
auto res = w.exec_params("SELECT h.hook_url "
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 "

View File

@ -64,7 +64,7 @@ pub extern "C" fn smee_client_notify_network_joined(
smee_instance: *mut SmeeClient,
network_id: *const c_char,
member_id: *const c_char,
hook_url: *const c_char,
hook_id: *const c_char,
src_ip: *const c_char,
) -> bool {
let nwid = unsafe {
@ -77,9 +77,9 @@ pub extern "C" fn smee_client_notify_network_joined(
CStr::from_ptr(member_id).to_str().unwrap()
};
let url = unsafe {
assert!(!hook_url.is_null());
CStr::from_ptr(hook_url).to_str().unwrap()
let hid = unsafe {
assert!(!hook_id.is_null());
CStr::from_ptr(hook_id).to_str().unwrap()
};
let src = unsafe {
@ -95,7 +95,7 @@ pub extern "C" fn smee_client_notify_network_joined(
&mut *smee_instance
};
let params = NetworkJoinedParams::new(nwid, mem_id, url, src);
let params = NetworkJoinedParams::new(nwid, mem_id, hid, src);
match smee.notify_network_joined(params) {
Ok(()) => true,

View File

@ -32,19 +32,19 @@ pub struct NetworkJoinedParams {
#[serde(rename = "MemberID")]
pub member_id: String,
#[serde(rename = "HookURL")]
pub hook_url: String,
#[serde(rename = "HookID")]
pub hook_id: String,
#[serde(rename = "SrcIP")]
pub src_ip: Option<String>,
}
impl NetworkJoinedParams {
fn new(network_id: &str, member_id: &str, hook_url: &str, src_ip: Option<&str>) -> Self {
fn new(network_id: &str, member_id: &str, hook_id: &str, src_ip: Option<&str>) -> Self {
Self {
network_id: network_id.to_string(),
member_id: member_id.to_string(),
hook_url: hook_url.to_string(),
hook_id: hook_id.to_string(),
src_ip: match src_ip {
Some(x) => Some(x.to_string()),
None => None,