Skip to content

Commit

Permalink
Fix empty sync messages being sent (#346)
Browse files Browse the repository at this point in the history
and always make sure we send sync messages unidentified as Signal-Android does.

This happened when giving `send_message` a `SyncMessage` to one self.
In that case, the message would not be sent and instead
`create_multi_device_sent_transcript_content` would create a new sync
message, which is empty as the `SyncMessage` is neither a `DataMessage`
nor an `EditMessage`.

This PR changes the condition to ignore sync messages.

Co-authored-by: Gabriel Féron <[email protected]>
  • Loading branch information
Schmiddiii and gferon authored Nov 19, 2024
1 parent c6b6eac commit 268e0c4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ where
) -> SendMessageResult {
let content_body = message.into();
let message_to_self = recipient == &self.local_aci;
let sync_message =
matches!(content_body, ContentBody::SynchronizeMessage(..));
let is_multi_device = self.is_multi_device().await;

use crate::proto::data_message::Flags;
Expand All @@ -370,7 +372,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 {
if message_to_self && is_multi_device && !sync_message {
debug!("sending note to self");
let sync_message = self
.create_multi_device_sent_transcript_content(
Expand All @@ -392,7 +394,8 @@ where
}

// don't send session enders as sealed sender
if end_session {
// sync messages are never sent as unidentified (reasons unclear), see: https://github.com/signalapp/Signal-Android/blob/main/libsignal-service/src/main/java/org/whispersystems/signalservice/api/SignalServiceMessageSender.java#L779
if end_session || sync_message {
unidentified_access.take();
}

Expand Down

0 comments on commit 268e0c4

Please sign in to comment.