Skip to content
Open
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
22 changes: 19 additions & 3 deletions src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ where
let message_to_self = recipient == &self.local_aci;
let sync_message =
matches!(content_body, ContentBody::SynchronizeMessage(..));
let syncable = is_syncable(&content_body);
let is_multi_device = self.is_multi_device().await;

use crate::proto::data_message::Flags;
Expand All @@ -376,7 +377,7 @@ where
};

// only send a sync message when sending to self and skip the rest of the process
if message_to_self && is_multi_device && !sync_message {
if message_to_self && is_multi_device && !sync_message && syncable {
debug!("sending note to self");
if let Some(sync_message) = self
.create_multi_device_sent_transcript_content(
Expand Down Expand Up @@ -427,7 +428,7 @@ where
_ => false,
};

if needs_sync || is_multi_device {
if (needs_sync || is_multi_device) && syncable {
debug!("sending multi-device sync message");
if let Some(sync) = if sync_message {
Some(content_body)
Expand Down Expand Up @@ -483,6 +484,7 @@ where
online: bool,
) -> Vec<SendMessageResult> {
let content_body: ContentBody = message.into();
let syncable = is_syncable(&content_body);
let mut results = vec![];

let mut needs_sync_in_results = false;
Expand Down Expand Up @@ -512,7 +514,7 @@ where
}

// we only need to send a synchronization message once
if needs_sync_in_results || self.is_multi_device().await {
if (needs_sync_in_results || self.is_multi_device().await) && syncable {
if let Some(sync_message) = self
.create_multi_device_sent_transcript_content(
None,
Expand Down Expand Up @@ -1103,3 +1105,17 @@ where
}))
}
}

/// Whether a content body can produce a sync transcript.
///
/// Only data messages, edit messages, and sync messages have sync
/// transcripts. Typing indicators, receipts, and other ephemeral
/// messages are not synced across devices via this path.
fn is_syncable(content_body: &ContentBody) -> bool {
matches!(
content_body,
ContentBody::DataMessage(_)
| ContentBody::EditMessage(_)
| ContentBody::SynchronizeMessage(_)
)
}
Loading