From f19ffa7cca270d3b17bb04a019f68678ce1faca5 Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Thu, 20 Mar 2025 01:22:50 +0200 Subject: [PATCH] messages-send: rigid checks on per-jid patch (fixes peer messages) Peer messages were causing an error here since they are only sent to the device (no otherJids) --- src/Socket/messages-send.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts index 952c5df..85e508f 100644 --- a/src/Socket/messages-send.ts +++ b/src/Socket/messages-send.ts @@ -286,20 +286,25 @@ export const makeMessagesSocket = (config: SocketConfig) => { } let shouldIncludeDeviceIdentity = false + const nodes = await Promise.all( patched.map( async patchedMessageWithJid => { const { recipientJid: jid, ...patchedMessage } = patchedMessageWithJid + if(!jid) { + return {} as BinaryNode + } + const bytes = encodeWAMessage(patchedMessage) const { type, ciphertext } = await signalRepository - .encryptMessage({ jid: jid!, data: bytes }) + .encryptMessage({ jid: jid, data: bytes }) if(type === 'pkmsg') { shouldIncludeDeviceIdentity = true } const node: BinaryNode = { tag: 'to', - attrs: { jid: jid! }, + attrs: { jid: jid }, content: [{ tag: 'enc', attrs: {