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:
parent
387ab475e2
commit
9491ec9bdb
@ -244,10 +244,12 @@ The global and per-account configurations can be overridden for specific session
|
|||||||
- `ackReaction`: `"always" | "mentions" | "never"`
|
- `ackReaction`: `"always" | "mentions" | "never"`
|
||||||
- `"always"`: Enables reactions (overrides global off/never).
|
- `"always"`: Enables reactions (overrides global off/never).
|
||||||
- `"never"`: Disables reactions (overrides global on/always/mentions).
|
- `"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.
|
- 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:** 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:**
|
**Per-account override:**
|
||||||
```json
|
```json
|
||||||
|
|||||||
@ -281,6 +281,20 @@ describe("shouldAckReactionForWhatsApp", () => {
|
|||||||
sessionMode: "mentions", // Session override ON (if mentioned)
|
sessionMode: "mentions", // Session override ON (if mentioned)
|
||||||
}),
|
}),
|
||||||
).toBe(true);
|
).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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,7 @@ export function shouldAckReactionForWhatsApp(params: {
|
|||||||
if (params.sessionMode === "never") return false;
|
if (params.sessionMode === "never") return false;
|
||||||
if (params.sessionMode === "always") return true;
|
if (params.sessionMode === "always") return true;
|
||||||
if (params.sessionMode === "mentions") {
|
if (params.sessionMode === "mentions") {
|
||||||
|
// Strict mention-only: explicit session override should not bypass via activation
|
||||||
return shouldAckReaction({
|
return shouldAckReaction({
|
||||||
scope: "group-mentions",
|
scope: "group-mentions",
|
||||||
isDirect: params.isDirect,
|
isDirect: params.isDirect,
|
||||||
@ -52,7 +53,7 @@ export function shouldAckReactionForWhatsApp(params: {
|
|||||||
requireMention: true,
|
requireMention: true,
|
||||||
canDetectMention: true,
|
canDetectMention: true,
|
||||||
effectiveWasMentioned: params.wasMentioned,
|
effectiveWasMentioned: params.wasMentioned,
|
||||||
shouldBypassMention: params.groupActivated,
|
// Note: intentionally not passing shouldBypassMention here
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user