Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(engine): surface mentionedIds on IncomingMessage
dallascyclist6c9d0e89df81
diff --git a/src/engine/adapters/message-mapper.spec.ts b/src/engine/adapters/message-mapper.spec.tsindex b3d4a88ac..25159670d 100644--- a/src/engine/adapters/message-mapper.spec.ts+++ b/src/engine/adapters/message-mapper.spec.ts@@ -72,6 +72,16 @@ describe('buildIncomingMessageBase', () => {expect(r.chatId).toBe('[email protected]');expect(r.isGroup).toBe(true);});++ it('maps mentionedIds when present', () => {+ const r = buildIncomingMessageBase({ ...base, mentionedIds: ['222@lid', '333@lid'] });+ expect(r.mentionedIds).toEqual(['222@lid', '333@lid']);+ });++ it('omits mentionedIds when absent or empty', () => {+ expect(buildIncomingMessageBase(base).mentionedIds).toBeUndefined();+ expect(buildIncomingMessageBase({ ...base, mentionedIds: [] }).mentionedIds).toBeUndefined();+ });});describe('mapWwebjsMessageType (engine type-token -> neutral MessageType boundary, #265)', () => {diff --git a/src/engine/adapters/message-mapper.ts b/src/engine/adapters/message-mapper.tsindex a6ebc48a9..4776e74ad 100644--- a/src/engine/adapters/message-mapper.ts+++ b/src/engine/adapters/message-mapper.ts@@ -49,6 +49,8 @@ export interface RawMessageFields {fromMe: boolean;/** Set on group messages: the participant WID that actually sent the message. */author?: string;+ /** WIDs @mentioned in the message; whatsapp-web.js attaches this to every Message. */+ mentionedIds?: string[];/** Raw wwebjs payload; `notifyName` carries the sender's push name without an extra lookup. */_data?: { notifyName?: string };}@@ -82,6 +84,11 @@ export function buildIncomingMessageBase(msg: RawMessageFields): IncomingMessageincoming.author = msg.author;}+ // @mentioned WIDs, when present — used for command targeting (e.g. `/tr grant @user`).+ if (msg.mentionedIds && msg.mentionedIds.length > 0) {+ incoming.mentionedIds = msg.mentionedIds;+ }+// Flag senders identified by a WhatsApp privacy id (`@lid`) so engine-neutral code can opt to// resolve a phone number without matching the engine-specific JID scheme itself (#263).const senderJid = msg.author ?? msg.from;diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.tsindex ffd2cde94..c189205c5 100644--- a/src/engine/interfaces/whatsapp-engine.interface.ts+++ b/src/engine/interfaces/whatsapp-engine.interface.ts@@ -57,6 +57,8 @@ export interface IncomingMessage {isStatusBroadcast?: boolean;/** For group messages, the WID of the participant who actually sent it (`from` is the group JID there). */author?: string;+ /** WIDs @mentioned in the message (empty/absent when none). Surfaced for command targeting. */+ mentionedIds?: string[];/*** Set by the adapter when the sender is identified by a privacy id (e.g. a WhatsApp `@lid`) rather* than a phone number, so engine-neutral code can decide whether to attempt phone resolution without