Skip to content

Commit

Permalink
Update FfiGroup to use added_by_address
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieobject committed Apr 10, 2024
1 parent a6fe203 commit 2826cac
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ impl FfiConversations {
inner_client: self.inner_client.clone(),
group_id: convo.group_id,
created_at_ns: convo.created_at_ns,
added_by_address: Some(self.inner_client.account_address()),
});

Ok(out)
Expand All @@ -236,6 +237,7 @@ impl FfiConversations {
inner_client: self.inner_client.clone(),
group_id: group.group_id,
created_at_ns: group.created_at_ns,
added_by_address: group.added_by_address,
});

Ok(out)
Expand Down Expand Up @@ -265,6 +267,7 @@ impl FfiConversations {
inner_client: self.inner_client.clone(),
group_id: group.group_id,
created_at_ns: group.created_at_ns,
added_by_address: group.added_by_address,
})
})
.collect();
Expand All @@ -284,6 +287,7 @@ impl FfiConversations {
inner_client: client.clone(),
group_id: convo.group_id,
created_at_ns: convo.created_at_ns,
added_by_address: convo.added_by_address,
}))
},
|| {}, // on_close_callback
Expand Down Expand Up @@ -317,6 +321,7 @@ pub struct FfiGroup {
inner_client: Arc<RustXmtpClient>,
group_id: Vec<u8>,
created_at_ns: i64,
added_by_address: Option<String>,
}

#[derive(uniffi::Record)]
Expand All @@ -339,7 +344,7 @@ impl FfiGroup {
self.inner_client.as_ref(),
self.group_id.clone(),
self.created_at_ns,
None,
self.added_by_address.clone(),
);

group.send_message(content_bytes.as_slice()).await?;
Expand All @@ -352,14 +357,18 @@ impl FfiGroup {
self.inner_client.as_ref(),
self.group_id.clone(),
self.created_at_ns,
None,
self.added_by_address.clone(),
);

group.sync().await?;

Ok(())
}

pub fn who_added_me(&self) -> Option<String> {
self.added_by_address.clone()
}

pub fn find_messages(
&self,
opts: FfiListMessagesOptions,
Expand All @@ -368,7 +377,7 @@ impl FfiGroup {
self.inner_client.as_ref(),
self.group_id.clone(),
self.created_at_ns,
None,
self.added_by_address.clone(),
);

let messages: Vec<FfiMessage> = group
Expand All @@ -394,7 +403,7 @@ impl FfiGroup {
self.inner_client.as_ref(),
self.group_id.clone(),
self.created_at_ns,
None,
self.added_by_address.clone(),
);
let message = group.process_streamed_group_message(envelope_bytes).await?;
let ffi_message = message.into();
Expand All @@ -407,7 +416,7 @@ impl FfiGroup {
self.inner_client.as_ref(),
self.group_id.clone(),
self.created_at_ns,
None,
self.added_by_address.clone(),
);

let members: Vec<FfiGroupMember> = group
Expand All @@ -429,7 +438,7 @@ impl FfiGroup {
self.inner_client.as_ref(),
self.group_id.clone(),
self.created_at_ns,
None,
self.added_by_address.clone(),
);

group.add_members(account_addresses).await?;
Expand All @@ -442,7 +451,7 @@ impl FfiGroup {
self.inner_client.as_ref(),
self.group_id.clone(),
self.created_at_ns,
None,
self.added_by_address.clone(),
);

group.remove_members(account_addresses).await?;
Expand Down Expand Up @@ -478,7 +487,7 @@ impl FfiGroup {
self.inner_client.as_ref(),
self.group_id.clone(),
self.created_at_ns,
None,
self.added_by_address.clone(),
);

Ok(group.is_active()?)
Expand All @@ -489,7 +498,7 @@ impl FfiGroup {
self.inner_client.as_ref(),
self.group_id.clone(),
self.created_at_ns,
None,
self.added_by_address.clone(),
);

let metadata = group.metadata()?;
Expand Down

0 comments on commit 2826cac

Please sign in to comment.