fix: honor whatsapp per-group mention overrides

This commit is contained in:
Peter Steinberger
2026-01-03 17:51:10 +01:00
parent dd6b9b510b
commit 591773715e
3 changed files with 69 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ import { loadConfig } from "../config/config.js";
import {
DEFAULT_IDLE_MINUTES,
loadSessionStore,
resolveGroupSessionKey,
resolveSessionKey,
resolveStorePath,
saveSessionStore,
@@ -813,8 +814,16 @@ export async function monitorWebProvider(
.join(", ");
};
const resolveGroupResolution = (conversationId: string) =>
resolveGroupSessionKey({
From: conversationId,
ChatType: "group",
Surface: "whatsapp",
});
const resolveGroupRequireMentionFor = (conversationId: string) => {
const groupConfig = cfg.whatsapp?.groups?.[conversationId];
const groupId = resolveGroupResolution(conversationId)?.id ?? conversationId;
const groupConfig = cfg.whatsapp?.groups?.[groupId];
if (typeof groupConfig?.requireMention === "boolean") {
return groupConfig.requireMention;
}
@@ -824,9 +833,11 @@ export async function monitorWebProvider(
};
const resolveGroupActivationFor = (conversationId: string) => {
const key = conversationId.startsWith("group:")
? conversationId
: `whatsapp:group:${conversationId}`;
const key =
resolveGroupResolution(conversationId)?.key ??
(conversationId.startsWith("group:")
? conversationId
: `whatsapp:group:${conversationId}`);
const store = loadSessionStore(sessionStorePath);
const entry = store[key];
const requireMention = resolveGroupRequireMentionFor(conversationId);