From 2afc933023b56db6610daafd478c76f5612e6567 Mon Sep 17 00:00:00 2001 From: K H Soh Date: Sat, 13 Dec 2025 22:01:33 +0800 Subject: [PATCH 1/3] Fixed contact_changed event to get the correct newId and oldId --- src/Client.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Client.js b/src/Client.js index 15727c8efb..dd6a98d2e2 100644 --- a/src/Client.js +++ b/src/Client.js @@ -723,10 +723,8 @@ class Client extends EventEmitter { /** @type {GroupNotification} object does not provide enough information about this event, so a @type {Message} object is used. */ const message = new Message(this, msg); - const newId = isParticipant ? msg.recipients[0] : msg.to; - const oldId = isParticipant - ? msg.author - : msg.templateParams.find((id) => id !== newId); + const newId = isParticipant ? msg.recipients[0] : msg._data.templateParams[1]; + const oldId = isParticipant ? msg.author : msg._data.templateParams[0]; /** * Emitted when a contact or a group participant changes their phone number. From 02eea50b4c3c03cf19e2d312497cb42bb4683acc Mon Sep 17 00:00:00 2001 From: K H Soh Date: Sun, 14 Dec 2025 22:08:03 +0800 Subject: [PATCH 2/3] Additional changes to get the actual phone number --- src/Client.js | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Client.js b/src/Client.js index dd6a98d2e2..c0f19be993 100644 --- a/src/Client.js +++ b/src/Client.js @@ -1379,8 +1379,8 @@ class Client extends EventEmitter { content instanceof Buttons, content instanceof List, Array.isArray(content) && - content.length > 0 && - content[0] instanceof Contact, + content.length > 0 && + content[0] instanceof Contact, ].includes(true) ) { console.warn( @@ -1401,8 +1401,8 @@ class Client extends EventEmitter { content instanceof Buttons, content instanceof List, Array.isArray(content) && - content.length > 0 && - content[0] instanceof Contact, + content.length > 0 && + content[0] instanceof Contact, ].includes(true) ) { console.warn( @@ -1784,10 +1784,10 @@ class Client extends EventEmitter { return !pinnedMsgs.length ? [] : await Promise.all( - pinnedMsgs.map((msg) => - window.WWebJS.getMessageModel(msg), - ), - ); + pinnedMsgs.map((msg) => + window.WWebJS.getMessageModel(msg), + ), + ); }, chatId); return pinnedMsgs.map((msg) => new Message(this, msg)); @@ -2089,9 +2089,9 @@ class Client extends EventEmitter { .Chat.find(chatId)); action === 'MUTE' ? await chat.mute.mute({ - expiration: unmuteDateTs, - sendDevice: true, - }) + expiration: unmuteDateTs, + sendDevice: true, + }) : await chat.mute.unmute({ sendDevice: true }); return { isMuted: chat.mute.expiration !== 0, @@ -2375,9 +2375,9 @@ class Client extends EventEmitter { window .require('WAWebCollections') .Chat.get(participant.wid) || - (await window - .require('WAWebCollections') - .Chat.find(participant.wid)), + (await window + .require('WAWebCollections') + .Chat.find(participant.wid)), createGroupResult.wid._serialized, createGroupResult.subject, participant.invite_code, @@ -2642,11 +2642,11 @@ class Client extends EventEmitter { countryCodes = countryCodes.length === 1 && - countryCodes[0] === currentRegion + countryCodes[0] === currentRegion ? countryCodes : countryCodes.filter((code) => - Object.keys(countryCodesIso).includes(code), - ); + Object.keys(countryCodesIso).includes(code), + ); const viewTypeMapping = { 0: 'RECOMMENDED', @@ -2685,12 +2685,12 @@ class Client extends EventEmitter { return channels ? await Promise.all( - channels.map((channel) => - window.WWebJS.getChatModel(channel, { - isChannel: true, - }), - ), - ) + channels.map((channel) => + window.WWebJS.getChatModel(channel, { + isChannel: true, + }), + ), + ) : []; }, searchOptions, From 9c5c292675481696539eab84e30ac79aadfd8cfb Mon Sep 17 00:00:00 2001 From: K H Soh Date: Sun, 15 Mar 2026 15:28:58 +0800 Subject: [PATCH 3/3] Changes to convert to whatsapp-web.js editor config style --- src/Client.js | 54 +++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/Client.js b/src/Client.js index c0f19be993..5c12fd9eb5 100644 --- a/src/Client.js +++ b/src/Client.js @@ -723,8 +723,12 @@ class Client extends EventEmitter { /** @type {GroupNotification} object does not provide enough information about this event, so a @type {Message} object is used. */ const message = new Message(this, msg); - const newId = isParticipant ? msg.recipients[0] : msg._data.templateParams[1]; - const oldId = isParticipant ? msg.author : msg._data.templateParams[0]; + const newId = isParticipant + ? msg.recipients[0] + : msg._data.templateParams[1]; + const oldId = isParticipant + ? msg.author + : msg._data.templateParams[0]; /** * Emitted when a contact or a group participant changes their phone number. @@ -1379,8 +1383,8 @@ class Client extends EventEmitter { content instanceof Buttons, content instanceof List, Array.isArray(content) && - content.length > 0 && - content[0] instanceof Contact, + content.length > 0 && + content[0] instanceof Contact, ].includes(true) ) { console.warn( @@ -1401,8 +1405,8 @@ class Client extends EventEmitter { content instanceof Buttons, content instanceof List, Array.isArray(content) && - content.length > 0 && - content[0] instanceof Contact, + content.length > 0 && + content[0] instanceof Contact, ].includes(true) ) { console.warn( @@ -1784,10 +1788,10 @@ class Client extends EventEmitter { return !pinnedMsgs.length ? [] : await Promise.all( - pinnedMsgs.map((msg) => - window.WWebJS.getMessageModel(msg), - ), - ); + pinnedMsgs.map((msg) => + window.WWebJS.getMessageModel(msg), + ), + ); }, chatId); return pinnedMsgs.map((msg) => new Message(this, msg)); @@ -2089,9 +2093,9 @@ class Client extends EventEmitter { .Chat.find(chatId)); action === 'MUTE' ? await chat.mute.mute({ - expiration: unmuteDateTs, - sendDevice: true, - }) + expiration: unmuteDateTs, + sendDevice: true, + }) : await chat.mute.unmute({ sendDevice: true }); return { isMuted: chat.mute.expiration !== 0, @@ -2375,9 +2379,9 @@ class Client extends EventEmitter { window .require('WAWebCollections') .Chat.get(participant.wid) || - (await window - .require('WAWebCollections') - .Chat.find(participant.wid)), + (await window + .require('WAWebCollections') + .Chat.find(participant.wid)), createGroupResult.wid._serialized, createGroupResult.subject, participant.invite_code, @@ -2642,11 +2646,11 @@ class Client extends EventEmitter { countryCodes = countryCodes.length === 1 && - countryCodes[0] === currentRegion + countryCodes[0] === currentRegion ? countryCodes : countryCodes.filter((code) => - Object.keys(countryCodesIso).includes(code), - ); + Object.keys(countryCodesIso).includes(code), + ); const viewTypeMapping = { 0: 'RECOMMENDED', @@ -2685,12 +2689,12 @@ class Client extends EventEmitter { return channels ? await Promise.all( - channels.map((channel) => - window.WWebJS.getChatModel(channel, { - isChannel: true, - }), - ), - ) + channels.map((channel) => + window.WWebJS.getChatModel(channel, { + isChannel: true, + }), + ), + ) : []; }, searchOptions,