From 2f16634efb0e70c4c007de1f0d422d27176379ed Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Sun, 31 Mar 2024 11:16:52 -0700 Subject: [PATCH] Push notification follow ups (#604) * only return the public installation id for this client * add a test for it * cargo changes * fix up the styling issues --- .github/CODEOWNERS | 2 +- bindings_ffi/src/mls.rs | 7 ++---- xmtp_mls/src/groups/subscriptions.rs | 34 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index be506e717..428c38194 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ # Global rule: -* @xmtp/messaging +* @xmtp/Engineering *.md @fabriguespe diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index d40660d58..b5944251c 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -138,11 +138,8 @@ impl FfiXmtpClient { Ok(results) } - pub async fn installation_ids(&self) -> Result>, GenericError> { - let address = self.inner_client.account_address(); - let installations = self.inner_client.get_all_active_installation_ids(vec![address]).await?; - - Ok(installations) + pub fn installation_id(&self) -> Vec { + self.inner_client.installation_public_key() } } diff --git a/xmtp_mls/src/groups/subscriptions.rs b/xmtp_mls/src/groups/subscriptions.rs index 13735bab4..41122d3fa 100644 --- a/xmtp_mls/src/groups/subscriptions.rs +++ b/xmtp_mls/src/groups/subscriptions.rs @@ -93,11 +93,45 @@ where #[cfg(test)] mod tests { + use prost::Message; use xmtp_cryptography::utils::generate_local_wallet; + use xmtp_proto::xmtp::mls::api::v1::GroupMessage; use crate::{builder::ClientBuilder, storage::group_message::GroupMessageKind}; use futures::StreamExt; + #[tokio::test(flavor = "multi_thread", worker_threads = 1)] + async fn test_decode_group_message_bytes() { + let amal = ClientBuilder::new_test_client(&generate_local_wallet()).await; + let bola = ClientBuilder::new_test_client(&generate_local_wallet()).await; + + let amal_group = amal.create_group(None).unwrap(); + // Add bola + amal_group + .add_members_by_installation_id(vec![bola.installation_public_key()]) + .await + .unwrap(); + + amal_group.send_message("hello".as_bytes()).await.unwrap(); + let messages = amal + .api_client + .query_group_messages(amal_group.clone().group_id, None) + .await + .expect("read topic"); + let message = messages.first().unwrap(); + let mut message_bytes: Vec = Vec::new(); + message.encode(&mut message_bytes).unwrap(); + let message_again = amal_group + .process_streamed_group_message(message_bytes) + .await; + + if let Ok(message) = message_again { + assert_eq!(message.group_id, amal_group.clone().group_id) + } else { + assert!(false) + } + } + #[tokio::test(flavor = "multi_thread", worker_threads = 10)] async fn test_subscribe_messages() { let amal = ClientBuilder::new_test_client(&generate_local_wallet()).await;