Skip to content

Commit 6bd613d

Browse files
Should push follow ups (#1722)
* another wasm bump * update protos * mark cargo clippy happy * read should push from queryable content * fix typo; formatting * add some logging * more debug log * Revert "more debug log" This reverts commit b8687aa. * Revert "add some logging" This reverts commit 5c107f4. --------- Co-authored-by: cameronvoell <cameronvoell@users.noreply.github.com>
1 parent ec56c11 commit 6bd613d

File tree

11 files changed

+996
-1011
lines changed

11 files changed

+996
-1011
lines changed

bindings_node/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# @xmtp/node-bindings
22

3+
## 0.0.41
4+
5+
- Fix `should_push` field on messages for push notifications
6+
37
## 0.0.40
48

59
- Fixed Rust Panic Error on Streams

bindings_node/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xmtp/node-bindings",
3-
"version": "0.0.40",
3+
"version": "0.0.41",
44
"repository": {
55
"type": "git",
66
"url": "git+https://git@github.com/xmtp/libxmtp.git",

bindings_wasm/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# @xmtp/wasm-bindings
22

3+
## 0.0.21
4+
5+
- Fix `should_push` field on messages for push notifications
6+
37
## 0.0.20
48

59
- Fixed Rust Panic Error on Streams

bindings_wasm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xmtp/wasm-bindings",
3-
"version": "0.0.20",
3+
"version": "0.0.21",
44
"type": "module",
55
"license": "MIT",
66
"description": "WASM bindings for the libXMTP rust library",

xmtp_api/src/test_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn build_group_messages(num_messages: usize, group_id: Vec<u8>) -> Vec<Group
4343
group_id: group_id.clone(),
4444
data: vec![i as u8],
4545
sender_hmac: vec![],
46-
should_push: Some(true),
46+
should_push: true,
4747
})),
4848
})
4949
}

xmtp_mls/src/groups/device_sync.rs

+15-25
Original file line numberDiff line numberDiff line change
@@ -438,20 +438,15 @@ where
438438
let content = DeviceSyncContent::Request(request.clone());
439439
let content_bytes = serde_json::to_vec(&content)?;
440440

441-
let _message_id = sync_group.prepare_message(
442-
&content_bytes,
443-
provider,
444-
{
445-
let request = request.clone();
446-
move |now| PlaintextEnvelope {
447-
content: Some(Content::V2(V2 {
448-
message_type: Some(MessageType::DeviceSyncRequest(request)),
449-
idempotency_key: now.to_string(),
450-
})),
451-
}
452-
},
453-
false,
454-
)?;
441+
let _message_id = sync_group.prepare_message(&content_bytes, provider, {
442+
let request = request.clone();
443+
move |now| PlaintextEnvelope {
444+
content: Some(Content::V2(V2 {
445+
message_type: Some(MessageType::DeviceSyncRequest(request)),
446+
idempotency_key: now.to_string(),
447+
})),
448+
}
449+
})?;
455450

456451
// publish the intent
457452
sync_group.publish_intents(provider).await?;
@@ -512,17 +507,12 @@ where
512507
(content_bytes, contents)
513508
};
514509

515-
sync_group.prepare_message(
516-
&content_bytes,
517-
provider,
518-
|now| PlaintextEnvelope {
519-
content: Some(Content::V2(V2 {
520-
message_type: Some(MessageType::DeviceSyncReply(contents)),
521-
idempotency_key: now.to_string(),
522-
})),
523-
},
524-
false,
525-
)?;
510+
sync_group.prepare_message(&content_bytes, provider, |now| PlaintextEnvelope {
511+
content: Some(Content::V2(V2 {
512+
message_type: Some(MessageType::DeviceSyncReply(contents)),
513+
idempotency_key: now.to_string(),
514+
})),
515+
})?;
526516

527517
sync_group.publish_intents(provider).await?;
528518

xmtp_mls/src/groups/device_sync/preference_sync.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,12 @@ impl UserPreferenceUpdate {
3131
.collect::<Result<Vec<_>, _>>()?;
3232
let update_proto = UserPreferenceUpdateProto { contents: updates };
3333
let content_bytes = serde_json::to_vec(&update_proto)?;
34-
sync_group.prepare_message(
35-
&content_bytes,
36-
&provider,
37-
|now| PlaintextEnvelope {
38-
content: Some(Content::V2(V2 {
39-
message_type: Some(MessageType::UserPreferenceUpdate(update_proto)),
40-
idempotency_key: now.to_string(),
41-
})),
42-
},
43-
false,
44-
)?;
34+
sync_group.prepare_message(&content_bytes, &provider, |now| PlaintextEnvelope {
35+
content: Some(Content::V2(V2 {
36+
message_type: Some(MessageType::UserPreferenceUpdate(update_proto)),
37+
idempotency_key: now.to_string(),
38+
})),
39+
})?;
4540

4641
sync_group.publish_intents(&provider).await?;
4742

xmtp_mls/src/groups/mls_sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ where
17161716
version: Some(GroupMessageInputVersion::V1(GroupMessageInputV1 {
17171717
data: payload.to_vec(),
17181718
sender_hmac: sender_hmac.into_bytes().to_vec(),
1719-
should_push: Some(should_push),
1719+
should_push,
17201720
})),
17211721
});
17221722
}

xmtp_mls/src/groups/mod.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -795,12 +795,8 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
795795
self.maybe_update_installations(provider, update_interval_ns)
796796
.await?;
797797

798-
let message_id = self.prepare_message(
799-
message,
800-
provider,
801-
|now| Self::into_envelope(message, now),
802-
true,
803-
)?;
798+
let message_id =
799+
self.prepare_message(message, provider, |now| Self::into_envelope(message, now))?;
804800

805801
self.sync_until_last_intent_resolved(provider).await?;
806802
// implicitly set group consent state to allowed
@@ -838,12 +834,8 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
838834
/// Send a message, optimistically returning the ID of the message before the result of a message publish.
839835
pub fn send_message_optimistic(&self, message: &[u8]) -> Result<Vec<u8>, GroupError> {
840836
let provider = self.mls_provider()?;
841-
let message_id = self.prepare_message(
842-
message,
843-
&provider,
844-
|now| Self::into_envelope(message, now),
845-
true,
846-
)?;
837+
let message_id =
838+
self.prepare_message(message, &provider, |now| Self::into_envelope(message, now))?;
847839
Ok(message_id)
848840
}
849841

@@ -877,7 +869,6 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
877869
message: &[u8],
878870
provider: &XmtpOpenMlsProvider,
879871
envelope: F,
880-
should_push: bool,
881872
) -> Result<Vec<u8>, GroupError>
882873
where
883874
F: FnOnce(i64) -> PlaintextEnvelope,
@@ -890,11 +881,17 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
890881
.map_err(GroupError::EncodeError)?;
891882

892883
let intent_data: Vec<u8> = SendMessageIntentData::new(encoded_envelope).into();
893-
self.queue_intent(provider, IntentKind::SendMessage, intent_data, should_push)?;
884+
let queryable_content_fields: QueryableContentFields =
885+
Self::extract_queryable_content_fields(message);
886+
self.queue_intent(
887+
provider,
888+
IntentKind::SendMessage,
889+
intent_data,
890+
queryable_content_fields.should_push,
891+
)?;
894892

895893
// store this unpublished message locally before sending
896894
let message_id = calculate_message_id(&self.group_id, message, &now.to_string());
897-
let queryable_content_fields = Self::extract_queryable_content_fields(message);
898895
let group_message = StoredGroupMessage {
899896
id: message_id.clone(),
900897
group_id: self.group_id.clone(),

0 commit comments

Comments
 (0)