From 1c5c59f33726ba182ee91d381685b3da5373a803 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Thu, 19 Dec 2024 17:02:48 -0800 Subject: [PATCH] Hmac Key updates (#1439) * update the hmac keys to return the conversation id * fix lint issue --- bindings_ffi/src/mls.rs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index 4ac46b3c1..193ea8732 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -534,24 +534,6 @@ impl FfiXmtpClient { scw_verifier: self.inner_client.scw_verifier().clone().clone(), })) } - - pub fn get_hmac_keys(&self) -> Result, GenericError> { - let inner = self.inner_client.as_ref(); - let conversations = inner.find_groups(GroupQueryArgs::default())?; - - let mut keys = vec![]; - for conversation in conversations { - let mut k = conversation - .hmac_keys(-1..=1)? - .into_iter() - .map(Into::into) - .collect::>(); - - keys.append(&mut k); - } - - Ok(keys) - } } impl From for FfiHmacKey { @@ -1110,6 +1092,25 @@ impl FfiConversations { FfiStreamCloser::new(handle) } + + pub fn get_hmac_keys(&self) -> Result, Vec>, GenericError> { + let inner = self.inner_client.as_ref(); + let conversations = inner.find_groups(GroupQueryArgs::default())?; + + let mut hmac_map = HashMap::new(); + for conversation in conversations { + let id = conversation.group_id.clone(); + let keys = conversation + .hmac_keys(-1..=1)? + .into_iter() + .map(Into::into) + .collect::>(); + + hmac_map.insert(id, keys); + } + + Ok(hmac_map) + } } impl From for ConversationType {