Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push notification follow ups #604

Merged
merged 5 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per Nicks feedback in the original PR probably don't need the whole list just the one for the device of this client.

}

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 @@ -86,18 +86,52 @@
cursor: 0,
},
)]),
move |message| callback(message),

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

View workflow job for this annotation

GitHub Actions / workspace

redundant closure

warning: redundant closure --> xmtp_mls/src/groups/subscriptions.rs:89:13 | 89 | move |message| callback(message), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `callback` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure = note: `#[warn(clippy::redundant_closure)]` on by default
)?)
}
}

#[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
Loading