From 1d57f383236340e98d710aa181e5af8e83c843e5 Mon Sep 17 00:00:00 2001 From: Emanuele Ingrosso Date: Fri, 21 Jul 2023 10:25:32 +0200 Subject: [PATCH] Add "+" to the beginning of jids if not present in the onWhatsApp method In Baileys 5.x a "+" was always added at the beginning of the jids provided to the onWhatsApp method. This was removed later in the 6.x version and has created a subtle problem. Many phone numbers where correctly verified but for some reason french mobile number (starting with 336 or 337) always returned an undefined result (maybe there were problems with some other countries too, I couldn't verify). Adding back the "+" (if missing) should fix the problem. --- src/Socket/chats.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 2932c42..10e11a3 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -168,15 +168,19 @@ export const makeChatsSocket = (config: SocketConfig) => { const onWhatsApp = async(...jids: string[]) => { const query = { tag: 'contact', attrs: {} } - const list = jids.map((jid) => ({ - tag: 'user', - attrs: {}, - content: [{ - tag: 'contact', + const list = jids.map((jid) => ( + const content = (!jid.startsWith('+')) ? `+${jid}` : jid; + + return { + tag: 'user', attrs: {}, - content: jid, - }], - })) + content: [{ + tag: 'contact', + attrs: {}, + content, + }], + } + )) const results = await interactiveQuery(list, query) return results.map(user => {