From d9fed62d00ecdef0be1fb1f2afd0fdef55de738a Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Fri, 26 Sep 2025 10:44:30 +0300 Subject: [PATCH] message: Add addressing mode --- src/Socket/socket.ts | 7 ++++--- src/Types/Message.ts | 1 + src/Utils/decode-wa-message.ts | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index 96c74cb9..dcbe0983 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -261,22 +261,23 @@ export const makeSocket = (config: SocketConfig) => { const onWhatsApp = async (...jids: string[]) => { let usyncQuery = new USyncQuery().withLIDProtocol() - let contactEnabled = false; + let contactEnabled = false for (const jid of jids) { if (isLidUser(jid)) { // usyncQuery.withUser(new USyncUser().withLid(jid)) // intentional but needs JID too - continue; + continue } else { if (!contactEnabled) { contactEnabled = true usyncQuery = usyncQuery.withContactProtocol() } + const phone = `+${jid.replace('+', '').split('@')[0]?.split(':')[0]}` usyncQuery.withUser(new USyncUser().withPhone(phone)) } } - if (usyncQuery.users.length == 0) { + if (usyncQuery.users.length === 0) { return [] // return early without forcing an empty query } diff --git a/src/Types/Message.ts b/src/Types/Message.ts index 57322691..5005b022 100644 --- a/src/Types/Message.ts +++ b/src/Types/Message.ts @@ -17,6 +17,7 @@ export type WAMessageKey = proto.IMessageKey & { remoteJidAlt?: string participantAlt?: string server_id?: string + addressingMode?: string isViewOnce?: boolean // TODO: remove out of the message key, place in WebMessageInfo } export type WATextMessage = proto.Message.IExtendedTextMessage diff --git a/src/Utils/decode-wa-message.ts b/src/Utils/decode-wa-message.ts index 10306ade..9c31aa68 100644 --- a/src/Utils/decode-wa-message.ts +++ b/src/Utils/decode-wa-message.ts @@ -185,6 +185,7 @@ export function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: strin id: msgId, participant, participantAlt: isJidGroup(chatId) ? addressingContext.senderAlt : undefined, + addressingMode: addressingContext.addressingMode, ...(msgType === 'newsletter' && stanza.attrs.server_id ? { server_id: stanza.attrs.server_id } : {}) }