Skip to content

Commit 1c5c59f

Browse files
authored
Hmac Key updates (#1439)
* update the hmac keys to return the conversation id * fix lint issue
1 parent a0791f0 commit 1c5c59f

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

bindings_ffi/src/mls.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -534,24 +534,6 @@ impl FfiXmtpClient {
534534
scw_verifier: self.inner_client.scw_verifier().clone().clone(),
535535
}))
536536
}
537-
538-
pub fn get_hmac_keys(&self) -> Result<Vec<FfiHmacKey>, GenericError> {
539-
let inner = self.inner_client.as_ref();
540-
let conversations = inner.find_groups(GroupQueryArgs::default())?;
541-
542-
let mut keys = vec![];
543-
for conversation in conversations {
544-
let mut k = conversation
545-
.hmac_keys(-1..=1)?
546-
.into_iter()
547-
.map(Into::into)
548-
.collect::<Vec<_>>();
549-
550-
keys.append(&mut k);
551-
}
552-
553-
Ok(keys)
554-
}
555537
}
556538

557539
impl From<HmacKey> for FfiHmacKey {
@@ -1110,6 +1092,25 @@ impl FfiConversations {
11101092

11111093
FfiStreamCloser::new(handle)
11121094
}
1095+
1096+
pub fn get_hmac_keys(&self) -> Result<HashMap<Vec<u8>, Vec<FfiHmacKey>>, GenericError> {
1097+
let inner = self.inner_client.as_ref();
1098+
let conversations = inner.find_groups(GroupQueryArgs::default())?;
1099+
1100+
let mut hmac_map = HashMap::new();
1101+
for conversation in conversations {
1102+
let id = conversation.group_id.clone();
1103+
let keys = conversation
1104+
.hmac_keys(-1..=1)?
1105+
.into_iter()
1106+
.map(Into::into)
1107+
.collect::<Vec<_>>();
1108+
1109+
hmac_map.insert(id, keys);
1110+
}
1111+
1112+
Ok(hmac_map)
1113+
}
11131114
}
11141115

11151116
impl From<FfiConversationType> for ConversationType {

0 commit comments

Comments
 (0)