Exclude invalid source-less incoming messages

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2026-03-30 14:27:25 -05:00
committed by GitHub
parent 806a66e006
commit 29ed67c04d
2 changed files with 75 additions and 2 deletions
+18 -2
View File
@@ -1612,9 +1612,25 @@ export class BackupExportStream extends Readable {
);
} else if (message.source) {
authorId = this.#getRecipientByE164(message.source, 'message.source');
} else if (isIncoming) {
if (conversation && isDirectConversation(conversation.attributes)) {
authorId = this.#getRecipientByConversationId(
conversation.id,
'message-missing-source'
);
}
if (authorId != null) {
log.warn(
`${message.sent_at}: Incoming message in group missing source, using conversation`
);
} else {
log.warn(
`${message.sent_at}: Incoming message in group or unknown conversation` +
' without source, dropping'
);
return undefined;
}
} else {
strictAssert(!isIncoming, 'Incoming message must have source');
// Author must be always present, even if we are directionless
authorId = me;
}
@@ -387,6 +387,63 @@ describe('backup/bubble messages', () => {
);
});
it('fixes source-missing incoming 1:1 messages', async () => {
await asymmetricRoundtripHarness(
[
{
conversationId: contactA.id,
id: generateGuid(),
type: 'incoming',
received_at: 3,
received_at_ms: 3,
sent_at: 3,
readStatus: ReadStatus.Unread,
seenStatus: SeenStatus.Unseen,
unidentifiedDeliveryReceived: true,
timestamp: 3,
body: 'hello',
},
],
[
{
conversationId: contactA.id,
id: generateGuid(),
type: 'incoming',
received_at: 3,
received_at_ms: 3,
sent_at: 3,
sourceServiceId: CONTACT_A,
readStatus: ReadStatus.Unread,
seenStatus: SeenStatus.Unseen,
unidentifiedDeliveryReceived: true,
timestamp: 3,
body: 'hello',
},
]
);
});
it('drops source-missing incoming group messages', async () => {
await asymmetricRoundtripHarness(
[
{
conversationId: gv2.id,
id: generateGuid(),
type: 'incoming',
received_at: 3,
received_at_ms: 3,
sent_at: 3,
readStatus: ReadStatus.Unread,
seenStatus: SeenStatus.Unseen,
unidentifiedDeliveryReceived: true,
timestamp: 3,
body: 'hello',
},
],
[]
);
});
it('drops misattributed incoming 1:1 messages', async () => {
await asymmetricRoundtripHarness(
[