fix: make session-level mentions strict (ignore activation bypass)

- Session override 'mentions' now requires actual @mention
- Does not bypass via groupActivated state
- Added test case for strict behavior
- Updated docs to clarify distinction from global config
This commit is contained in:
Keith the Silly Goose 2026-01-28 22:28:21 +13:00
parent 387ab475e2
commit 9491ec9bdb
3 changed files with 19 additions and 2 deletions

View File

@ -244,10 +244,12 @@ The global and per-account configurations can be overridden for specific session
- `ackReaction`: `"always" | "mentions" | "never"`
- `"always"`: Enables reactions (overrides global off/never).
- `"never"`: Disables reactions (overrides global on/always/mentions).
- `"mentions"`: Enforces mention-only reactions.
- `"mentions"`: Enforces **strict** mention-only reactions (requires actual @mention, ignores group activation state).
- Useful for disabling reactions in specific DMs (`"never"`) or forcing them in specific groups.
> **Note:** Setting `"mentions"` on a DM session effectively disables reactions for that DM, since direct messages don't have @mentions. Use `"always"` or `"never"` for DMs.
>
> **Note:** Unlike the global `group: "mentions"` setting which respects group activation state, the session-level `"mentions"` override is strict and always requires an actual @mention.
**Per-account override:**
```json

View File

@ -281,6 +281,20 @@ describe("shouldAckReactionForWhatsApp", () => {
sessionMode: "mentions", // Session override ON (if mentioned)
}),
).toBe(true);
// Session: MENTIONS is strict - does NOT bypass via groupActivated
expect(
shouldAckReactionForWhatsApp({
emoji: "👀",
isDirect: false,
isGroup: true,
directEnabled: true,
groupMode: "always",
wasMentioned: false, // Not mentioned
groupActivated: true, // But group is activated
sessionMode: "mentions", // Explicit mentions = strict, no bypass
}),
).toBe(false);
});
});

View File

@ -44,6 +44,7 @@ export function shouldAckReactionForWhatsApp(params: {
if (params.sessionMode === "never") return false;
if (params.sessionMode === "always") return true;
if (params.sessionMode === "mentions") {
// Strict mention-only: explicit session override should not bypass via activation
return shouldAckReaction({
scope: "group-mentions",
isDirect: params.isDirect,
@ -52,7 +53,7 @@ export function shouldAckReactionForWhatsApp(params: {
requireMention: true,
canDetectMention: true,
effectiveWasMentioned: params.wasMentioned,
shouldBypassMention: params.groupActivated,
// Note: intentionally not passing shouldBypassMention here
});
}