Skip to content

Commit

Permalink
Push notification follow ups (#604)
Browse files Browse the repository at this point in the history
* only return the public installation id for this client

* add a test for it

* cargo changes

* fix up the styling issues
  • Loading branch information
nplasterer authored Mar 31, 2024
1 parent 67a03a5 commit 2f16634
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Global rule:
* @xmtp/messaging
* @xmtp/Engineering
*.md @fabriguespe
7 changes: 2 additions & 5 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,8 @@ impl FfiXmtpClient {
Ok(results)
}

pub async fn installation_ids(&self) -> Result<Vec<Vec<u8>>, 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<u8> {
self.inner_client.installation_public_key()
}
}

Expand Down
34 changes: 34 additions & 0 deletions xmtp_mls/src/groups/subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check warning on line 98 in xmtp_mls/src/groups/subscriptions.rs

View workflow job for this annotation

GitHub Actions / Test

unused import: `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<u8> = 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;
Expand Down

0 comments on commit 2f16634

Please sign in to comment.