This commit is contained in:
Rajeh Taher
2023-10-01 14:16:29 +00:00
parent 0b2f4d0b42
commit 6546793ec6
3 changed files with 6 additions and 4 deletions

View File

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

View File

@@ -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' })
})