Skip to content

Commit

Permalink
update the hmac keys to return the conversation id
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 20, 2024
1 parent a0791f0 commit 1256e15
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,24 +534,6 @@ impl FfiXmtpClient {
scw_verifier: self.inner_client.scw_verifier().clone().clone(),
}))
}

pub fn get_hmac_keys(&self) -> Result<Vec<FfiHmacKey>, 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::<Vec<_>>();

keys.append(&mut k);
}

Ok(keys)
}
}

impl From<HmacKey> for FfiHmacKey {
Expand Down Expand Up @@ -1110,6 +1092,25 @@ impl FfiConversations {

FfiStreamCloser::new(handle)
}

pub fn get_hmac_keys(&self) -> Result<HashMap<Vec<u8>, Vec<FfiHmacKey>>, 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 mut keys = conversation
.hmac_keys(-1..=1)?
.into_iter()
.map(Into::into)
.collect::<Vec<_>>();

hmac_map.insert(id, keys);
}

Ok(hmac_map)
}
}

impl From<FfiConversationType> for ConversationType {
Expand Down

0 comments on commit 1256e15

Please sign in to comment.