Fix WhatsApp group access when senders are opaque LIDs.

Resolve LID to phone aliases before allowlist and @mention checks so
group prompts are not silently dropped after a working direct chat.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-05 15:56:24 +08:00
parent 7f1b9bd480
commit d9edca4d5f
9 changed files with 472 additions and 203 deletions

View file

@ -12,6 +12,7 @@ import { t } from '../shared/i18n.mjs';
import { ImagePromptError } from '../shared/image-prompt.mjs';
import { trackOutboundArtifactProviderPromise } from '../shared/semantic/artifact.mjs';
import { createWhatsappBridgeStatus, WhatsappHarnessBridge } from './whatsapp-bridge.mjs';
import { enrichWhatsappInboundIdentities } from './whatsapp-identity.mjs';
import {
WHATSAPP_ACCESS_MODES,
} from './config-store.mjs';
@ -637,6 +638,7 @@ export class WhatsappRuntime {
#client = null;
#bridge = null;
#starting = null;
#lidPnCache = new Map();
constructor({
config,
@ -709,12 +711,17 @@ export class WhatsappRuntime {
{ code: 'relink-required' },
)),
onMessage: async (raw, context) => {
const message = normalizeWhatsappMessage(raw, this.#config.accountJid, {
const normalized = normalizeWhatsappMessage(raw, this.#config.accountJid, {
download: createWhatsappMediaDownloader({
socket: context?.socket,
logger: this.#logger,
}),
});
const message = await enrichWhatsappInboundIdentities(normalized, raw, {
accountJid: this.#config.accountJid,
socket: context?.socket ?? this.#session?.socket,
lidPnCache: this.#lidPnCache,
});
if (!message || outboundIds.has(message.providerMessageId) || !this.#bridge) return;
this.#status.lastCheckedAt = Date.now();
await this.#bridge.accept(message);