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.
This commit is contained in:
Emanuele Ingrosso
2023-07-21 10:25:32 +02:00
committed by Codeboss
parent bdbff517ce
commit 1d57f38323

View File

@@ -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 => {