mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 19:01:47 +03:00
fix: include sender info for iMessage/Signal group messages
This commit is contained in:
@@ -184,4 +184,77 @@ describe("dispatchReplyFromConfig", () => {
|
||||
|
||||
expect(replyResolver).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("appends sender meta for non-direct chats when missing", async () => {
|
||||
mocks.tryFastAbortFromMessage.mockResolvedValue({
|
||||
handled: false,
|
||||
aborted: false,
|
||||
});
|
||||
const cfg = {} as ClawdbotConfig;
|
||||
const dispatcher = createDispatcher();
|
||||
const ctx: MsgContext = {
|
||||
Provider: "imessage",
|
||||
ChatType: "group",
|
||||
Body: "[iMessage group:1] hello",
|
||||
SenderName: "+15555550123",
|
||||
SenderId: "+15555550123",
|
||||
};
|
||||
|
||||
const replyResolver = vi.fn(async (resolvedCtx: MsgContext) => {
|
||||
expect(resolvedCtx.Body).toContain("\n[from: +15555550123]");
|
||||
return { text: "ok" } satisfies ReplyPayload;
|
||||
});
|
||||
|
||||
await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
|
||||
expect(replyResolver).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not append sender meta when Body already includes a from line", async () => {
|
||||
mocks.tryFastAbortFromMessage.mockResolvedValue({
|
||||
handled: false,
|
||||
aborted: false,
|
||||
});
|
||||
const cfg = {} as ClawdbotConfig;
|
||||
const dispatcher = createDispatcher();
|
||||
const ctx: MsgContext = {
|
||||
Provider: "whatsapp",
|
||||
ChatType: "group",
|
||||
Body: "[WhatsApp group:1] hello\\n[from: Bob (+222)]",
|
||||
SenderName: "Bob",
|
||||
SenderId: "+222",
|
||||
};
|
||||
|
||||
const replyResolver = vi.fn(async (resolvedCtx: MsgContext) => {
|
||||
expect(resolvedCtx.Body.match(/\\n\[from:/g)?.length ?? 0).toBe(1);
|
||||
return { text: "ok" } satisfies ReplyPayload;
|
||||
});
|
||||
|
||||
await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
|
||||
expect(replyResolver).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not append sender meta for other providers (scope is signal/imessage only)", async () => {
|
||||
mocks.tryFastAbortFromMessage.mockResolvedValue({
|
||||
handled: false,
|
||||
aborted: false,
|
||||
});
|
||||
const cfg = {} as ClawdbotConfig;
|
||||
const dispatcher = createDispatcher();
|
||||
const ctx: MsgContext = {
|
||||
Provider: "slack",
|
||||
OriginatingChannel: "slack",
|
||||
ChatType: "group",
|
||||
Body: "[Slack #room 2026-01-01T00:00Z] hi",
|
||||
SenderName: "Bob",
|
||||
SenderId: "U123",
|
||||
};
|
||||
|
||||
const replyResolver = vi.fn(async (resolvedCtx: MsgContext) => {
|
||||
expect(resolvedCtx.Body).not.toContain("[from:");
|
||||
return { text: "ok" } satisfies ReplyPayload;
|
||||
});
|
||||
|
||||
await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
|
||||
expect(replyResolver).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user