From 2826cac7bb2412c4dafde2c434f4c781940263c8 Mon Sep 17 00:00:00 2001 From: Ethan Mateja Date: Wed, 10 Apr 2024 10:32:48 -0700 Subject: [PATCH] Update FfiGroup to use added_by_address --- bindings_ffi/src/mls.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index c1f677f89..a25e79a7c 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -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) @@ -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) @@ -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(); @@ -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 @@ -317,6 +321,7 @@ pub struct FfiGroup { inner_client: Arc, group_id: Vec, created_at_ns: i64, + added_by_address: Option, } #[derive(uniffi::Record)] @@ -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?; @@ -352,7 +357,7 @@ impl FfiGroup { self.inner_client.as_ref(), self.group_id.clone(), self.created_at_ns, - None, + self.added_by_address.clone(), ); group.sync().await?; @@ -360,6 +365,10 @@ impl FfiGroup { Ok(()) } + pub fn who_added_me(&self) -> Option { + self.added_by_address.clone() + } + pub fn find_messages( &self, opts: FfiListMessagesOptions, @@ -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 = group @@ -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(); @@ -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 = group @@ -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?; @@ -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?; @@ -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()?) @@ -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()?;