fix(signal): land #31138 syncMessage presence filtering (@Sid-Qin)

Landed from contributor PR #31138 by @Sid-Qin.

Co-authored-by: Sid-Qin <sidqin0410@gmail.com>
This commit is contained in:
Peter Steinberger
2026-03-02 03:28:25 +00:00
parent 22666034a0
commit 08f8aea32e
3 changed files with 31 additions and 3 deletions

View File

@@ -201,4 +201,29 @@ describe("signal createSignalEventHandler inbound contract", () => {
expect(capture.ctx).toBeUndefined();
expect(dispatchInboundMessageMock).not.toHaveBeenCalled();
});
it("drops sync envelopes when syncMessage is present but null", async () => {
const handler = createSignalEventHandler(
createBaseSignalEventHandlerDeps({
cfg: {
messages: { inbound: { debounceMs: 0 } },
channels: { signal: { dmPolicy: "open", allowFrom: ["*"] } },
},
historyLimit: 0,
}),
);
await handler(
createSignalReceiveEvent({
syncMessage: null,
dataMessage: {
message: "replayed sentTranscript envelope",
attachments: [],
},
}),
);
expect(capture.ctx).toBeUndefined();
expect(dispatchInboundMessageMock).not.toHaveBeenCalled();
});
});

View File

@@ -438,9 +438,11 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
return;
}
// For non-own sync messages (e.g., messages synced from other devices),
// we could process them but for now we skip to be conservative
if (envelope.syncMessage) {
// Filter all sync messages (sentTranscript, readReceipts, etc.).
// signal-cli may set syncMessage to null instead of omitting it, so
// check property existence rather than truthiness to avoid replaying
// the bot's own sent messages on daemon restart.
if ("syncMessage" in envelope) {
return;
}