From bb25723b6ac019ec790c22b95738cc14a725f32a Mon Sep 17 00:00:00 2001 From: Adrien Date: Fri, 26 May 2023 19:12:58 +0800 Subject: [PATCH] fix: onWhatsApp query for multiple jids (#85) --- src/Socket/chats.ts | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 1a88161..eb731a2 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -167,22 +167,17 @@ export const makeChatsSocket = (config: SocketConfig) => { } const onWhatsApp = async(...jids: string[]) => { - const results = await interactiveQuery( - [ - { - tag: 'user', - attrs: {}, - content: jids.map( - jid => ({ - tag: 'contact', - attrs: {}, - content: `+${jid}` - }) - ) - } - ], - { tag: 'contact', attrs: {} } - ) + const query = { tag: 'contact', attrs: {} } + const list = jids.map((jid) => ({ + tag: 'user', + attrs: {}, + content: [{ + tag: 'contact', + attrs: {}, + content: jid, + }], + })) + const results = await interactiveQuery(list, query) return results.map(user => { const contact = getBinaryNodeChild(user, 'contact')