fix(whatsapp): pass authDir to jidToE164 for LID mention detection

WhatsApp group mentions using the new Linked ID format (@lid) were not
being detected because jidToE164() was called without the authDir needed
to find the LID reverse mapping files.

Now isBotMentioned() and debugMention() accept an optional authDir
parameter, which is passed through from account.authDir.
This commit is contained in:
Peter Siska
2026-01-10 22:40:19 +00:00
committed by Peter Steinberger
parent 5fa3ac1e01
commit 9cb1bfa1c1

View File

@@ -189,6 +189,7 @@ function buildMentionConfig(
function isBotMentioned(
msg: WebInboundMsg,
mentionCfg: MentionConfig,
authDir?: string,
): boolean {
const clean = (text: string) =>
// Remove zero-width and directionality markers WhatsApp injects around display names
@@ -198,7 +199,7 @@ function isBotMentioned(
if (msg.mentionedJids?.length && !isSelfChat) {
const normalizedMentions = msg.mentionedJids
.map((jid) => jidToE164(jid) ?? jid)
.map((jid) => jidToE164(jid, authDir ? { authDir } : undefined) ?? jid)
.filter(Boolean);
if (msg.selfE164 && normalizedMentions.includes(msg.selfE164)) return true;
if (msg.selfJid && msg.selfE164) {
@@ -230,8 +231,9 @@ function isBotMentioned(
function debugMention(
msg: WebInboundMsg,
mentionCfg: MentionConfig,
authDir?: string,
): { wasMentioned: boolean; details: Record<string, unknown> } {
const result = isBotMentioned(msg, mentionCfg);
const result = isBotMentioned(msg, mentionCfg, authDir);
const details = {
from: msg.from,
body: msg.body,
@@ -1584,7 +1586,7 @@ export async function monitorWebProvider(
groupHistories.set(groupHistoryKey, history);
}
const mentionDebug = debugMention(msg, mentionConfig);
const mentionDebug = debugMention(msg, mentionConfig, account.authDir);
replyLogger.debug(
{
conversationId,