mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 21:11:26 +00:00
fix(signal): canonicalize message targets in tool and inbound flows
This commit is contained in:
@@ -51,4 +51,41 @@ describe("signal createSignalEventHandler inbound contract", () => {
|
||||
expect(String(contextWithBody.Body ?? "")).toMatch(/Alice.*:/);
|
||||
expect(String(contextWithBody.Body ?? "")).not.toContain("[from:");
|
||||
});
|
||||
|
||||
it("normalizes direct chat To/OriginatingTo targets to canonical Signal ids", async () => {
|
||||
capturedCtx = undefined;
|
||||
|
||||
const handler = createSignalEventHandler(
|
||||
createBaseSignalEventHandlerDeps({
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
cfg: { messages: { inbound: { debounceMs: 0 } } } as any,
|
||||
historyLimit: 0,
|
||||
}),
|
||||
);
|
||||
|
||||
await handler({
|
||||
event: "receive",
|
||||
data: JSON.stringify({
|
||||
envelope: {
|
||||
sourceNumber: "+15550002222",
|
||||
sourceName: "Bob",
|
||||
timestamp: 1700000000001,
|
||||
dataMessage: {
|
||||
message: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
expect(capturedCtx).toBeTruthy();
|
||||
const context = capturedCtx as unknown as {
|
||||
ChatType?: string;
|
||||
To?: string;
|
||||
OriginatingTo?: string;
|
||||
};
|
||||
expect(context.ChatType).toBe("direct");
|
||||
expect(context.To).toBe("+15550002222");
|
||||
expect(context.OriginatingTo).toBe("+15550002222");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,6 +21,7 @@ import { createReplyDispatcherWithTyping } from "../../auto-reply/reply/reply-di
|
||||
import { resolveControlCommandGate } from "../../channels/command-gating.js";
|
||||
import { logInboundDrop, logTypingFailure } from "../../channels/logging.js";
|
||||
import { resolveMentionGatingWithBypass } from "../../channels/mention-gating.js";
|
||||
import { normalizeSignalMessagingTarget } from "../../channels/plugins/normalize/signal.js";
|
||||
import { createReplyPrefixOptions } from "../../channels/reply-prefix.js";
|
||||
import { recordInboundSession } from "../../channels/session.js";
|
||||
import { createTypingCallbacks } from "../../channels/typing.js";
|
||||
@@ -126,7 +127,10 @@ export function createSignalEventHandler(deps: SignalEventHandlerDeps) {
|
||||
}),
|
||||
});
|
||||
}
|
||||
const signalTo = entry.isGroup ? `group:${entry.groupId}` : `signal:${entry.senderRecipient}`;
|
||||
const signalToRaw = entry.isGroup
|
||||
? `group:${entry.groupId}`
|
||||
: `signal:${entry.senderRecipient}`;
|
||||
const signalTo = normalizeSignalMessagingTarget(signalToRaw) ?? signalToRaw;
|
||||
const inboundHistory =
|
||||
entry.isGroup && historyKey && deps.historyLimit > 0
|
||||
? (deps.groupHistories.get(historyKey) ?? []).map((historyEntry) => ({
|
||||
|
||||
Reference in New Issue
Block a user