diff --git a/extensions/whatsapp/src/auto-reply/monitor/group-gating.allowlist-warn.test.ts b/extensions/whatsapp/src/auto-reply/monitor/group-gating.allowlist-warn.test.ts index c6fea0db3e8e..fdec0d865ba6 100644 --- a/extensions/whatsapp/src/auto-reply/monitor/group-gating.allowlist-warn.test.ts +++ b/extensions/whatsapp/src/auto-reply/monitor/group-gating.allowlist-warn.test.ts @@ -90,7 +90,9 @@ describe("applyGroupGating allowlist drop warning", () => { expect(result).toEqual({ shouldProcess: false }); expect(warn).toHaveBeenCalledTimes(1); - expect(params.logVerbose).not.toHaveBeenCalled(); + expect(params.logVerbose).toHaveBeenCalledWith( + 'Dropping message from unregistered WhatsApp group unregistered@g.us. Add the group JID to channels.whatsapp.groups, or add "*" there to admit all groups. Sender authorization still applies.', + ); const [context, message] = warn.mock.calls[0] ?? []; expect(context).toMatchObject({ conversationId: "unregistered@g.us", @@ -153,14 +155,21 @@ describe("applyGroupGating allowlist drop warning", () => { expect(message).toContain("channels.whatsapp.groups"); }); - it("only warns once per conversation across repeated messages", async () => { + it("warns once but keeps verbose diagnostics per dropped message", async () => { const warn = vi.fn(); + const first = makeParams(makeUnregisteredGroupMsg("loud@g.us"), warn); + const second = makeParams(makeUnregisteredGroupMsg("loud@g.us"), warn); + const third = makeParams(makeUnregisteredGroupMsg("loud@g.us"), warn); - await applyGroupGating(makeParams(makeUnregisteredGroupMsg("loud@g.us"), warn)); - await applyGroupGating(makeParams(makeUnregisteredGroupMsg("loud@g.us"), warn)); - await applyGroupGating(makeParams(makeUnregisteredGroupMsg("loud@g.us"), warn)); + await applyGroupGating(first); + await applyGroupGating(second); + await applyGroupGating(third); expect(warn).toHaveBeenCalledTimes(1); + expect(warn.mock.calls[0]?.[1]).toContain("loud@g.us"); + expect(first.logVerbose).toHaveBeenCalledTimes(1); + expect(second.logVerbose).toHaveBeenCalledTimes(1); + expect(third.logVerbose).toHaveBeenCalledTimes(1); }); it("warns separately for distinct conversations", async () => { diff --git a/extensions/whatsapp/src/auto-reply/monitor/group-gating.ts b/extensions/whatsapp/src/auto-reply/monitor/group-gating.ts index a81c21a5e375..3542c48479fc 100644 --- a/extensions/whatsapp/src/auto-reply/monitor/group-gating.ts +++ b/extensions/whatsapp/src/auto-reply/monitor/group-gating.ts @@ -149,6 +149,9 @@ export async function applyGroupGating(params: ApplyGroupGatingParams) { `WhatsApp group ${params.conversationId} not in ${groupsPath} — inbound dropped. Add the group JID to ${groupsPath} (or add "*" there to admit all groups). Sender authorization still applies.`, ); } + params.logVerbose( + `Dropping message from unregistered WhatsApp group ${params.conversationId}. Add the group JID to channels.whatsapp.groups, or add "*" there to admit all groups. Sender authorization still applies.`, + ); return { shouldProcess: false }; } diff --git a/extensions/whatsapp/src/auto-reply/web-auto-reply-monitor.test.ts b/extensions/whatsapp/src/auto-reply/web-auto-reply-monitor.test.ts index d1e729061aa6..23300af30644 100644 --- a/extensions/whatsapp/src/auto-reply/web-auto-reply-monitor.test.ts +++ b/extensions/whatsapp/src/auto-reply/web-auto-reply-monitor.test.ts @@ -644,7 +644,7 @@ describe("applyGroupGating", () => { }); expect(result.shouldProcess).toBe(false); - expect(verboseLogs).not.toContain( + expect(verboseLogs).toContain( 'Dropping message from unregistered WhatsApp group 123@g.us. Add the group JID to channels.whatsapp.groups, or add "*" there to admit all groups. Sender authorization still applies.', ); });