From 7be1db3beb5d6577ee76088b5f78105fd8a76eee Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Wed, 8 Sep 2021 15:25:34 +0530 Subject: [PATCH] add inviteCode --- src/Connection/groups.ts | 10 +++++++++- src/Connection/messages.ts | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Connection/groups.ts b/src/Connection/groups.ts index a3085fa..9ee0a1c 100644 --- a/src/Connection/groups.ts +++ b/src/Connection/groups.ts @@ -222,7 +222,15 @@ const makeGroupsSocket = (config: SocketConfig) => { )) } return metadata - } + }, + inviteCode: async(jid: string) => { + const response = await sock.query({ + json: ['query', 'inviteCode', jid], + expect200: true, + requiresPhoneConnection: false + }) + return response.code as string + } } } diff --git a/src/Connection/messages.ts b/src/Connection/messages.ts index 89178de..87af84f 100644 --- a/src/Connection/messages.ts +++ b/src/Connection/messages.ts @@ -117,19 +117,19 @@ const makeMessagesSocket = (config: SocketConfig) => { if(message.message) { chatUpdate.t = +toNumber(message.messageTimestamp) - } - // add to count if the message isn't from me & there exists a message - if(!message.key.fromMe && message.message) { - chatUpdate.count = 1 - const participant = whatsappID(message.participant || jid) + // add to count if the message isn't from me & there exists a message + if(!message.key.fromMe) { + chatUpdate.count = 1 + const participant = whatsappID(message.participant || jid) - ev.emit( - 'presence.update', - { - jid, - presences: { [participant]: { lastKnownPresence: Presence.available } } - } - ) + ev.emit( + 'presence.update', + { + jid, + presences: { [participant]: { lastKnownPresence: Presence.available } } + } + ) + } } const ephemeralProtocolMsg = message.message?.ephemeralMessage?.message?.protocolMessage