mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 14:51:42 +00:00
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:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user