From 6546793ec63007b3313c0f402f2942c65c8aa6f7 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Sun, 1 Oct 2023 14:16:29 +0000 Subject: [PATCH] fixes --- src/Socket/messages-send.ts | 4 ++-- src/Socket/socket.ts | 5 +++-- src/Types/Contact.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts index 63dc4e2..5cb35b3 100644 --- a/src/Socket/messages-send.ts +++ b/src/Socket/messages-send.ts @@ -378,7 +378,7 @@ export const makeMessagesSocket = (config: SocketConfig) => { devices.push(...additionalDevices) } - const patched = await patchMessageBeforeSending(message, devices.map(d => jidEncode(d.user, d.domainType == 0 ? 's.whatsapp.net' : 'lid', d.device))) + const patched = await patchMessageBeforeSending(message, devices.map(d => jidEncode(d.user, sock.user?.id?.includes?.(d.user) ? 'lid' : 's.whatsapp.net', d.device))) const bytes = encodeWAMessage(patched) const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage( @@ -446,7 +446,7 @@ export const makeMessagesSocket = (config: SocketConfig) => { const otherJids: string[] = [] for(const { user, device } of devices) { const isMe = user === meUser - const jid = jidEncode(user, !isMe && isLid ? 'lid' : 's.whatsapp.net', device) + const jid = jidEncode(user, !isMe && isLid ? 'lid' : 's.whatsapp.net', device) if(isMe) { meJids.push(jid) } else { diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index 5c8440d..71f7d14 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -623,14 +623,15 @@ export const makeSocket = (config: SocketConfig) => { } }) // login complete - ws.on('CB:success', async (node) => { - console.log(node.attrs) // temporary log, don't merge before removing + ws.on('CB:success', async(node: BinaryNode) => { await uploadPreKeysToServerIfRequired() await sendPassiveIq('active') logger.info('opened connection to WA') clearTimeout(qrTimer) // will never happen in all likelyhood -- but just in case WA sends success on first try + ev.emit('creds.update', { me: { id: authState.creds.me!.id, lid: node.attrs.lid } }) + ev.emit('connection.update', { connection: 'open' }) }) diff --git a/src/Types/Contact.ts b/src/Types/Contact.ts index 5da78e8..0dd51f1 100644 --- a/src/Types/Contact.ts +++ b/src/Types/Contact.ts @@ -1,5 +1,6 @@ export interface Contact { id: string + lid?: string /** name of the contact, you have saved on your WA */ name?: string /** name of the contact, the contact has set on their own on WA */