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)
This commit is contained in:
Rajeh Taher
2025-03-20 01:22:50 +02:00
parent c96be39829
commit f19ffa7cca

View File

@@ -286,20 +286,25 @@ export const makeMessagesSocket = (config: SocketConfig) => {
} }
let shouldIncludeDeviceIdentity = false let shouldIncludeDeviceIdentity = false
const nodes = await Promise.all( const nodes = await Promise.all(
patched.map( patched.map(
async patchedMessageWithJid => { async patchedMessageWithJid => {
const { recipientJid: jid, ...patchedMessage } = patchedMessageWithJid const { recipientJid: jid, ...patchedMessage } = patchedMessageWithJid
if(!jid) {
return {} as BinaryNode
}
const bytes = encodeWAMessage(patchedMessage) const bytes = encodeWAMessage(patchedMessage)
const { type, ciphertext } = await signalRepository const { type, ciphertext } = await signalRepository
.encryptMessage({ jid: jid!, data: bytes }) .encryptMessage({ jid: jid, data: bytes })
if(type === 'pkmsg') { if(type === 'pkmsg') {
shouldIncludeDeviceIdentity = true shouldIncludeDeviceIdentity = true
} }
const node: BinaryNode = { const node: BinaryNode = {
tag: 'to', tag: 'to',
attrs: { jid: jid! }, attrs: { jid: jid },
content: [{ content: [{
tag: 'enc', tag: 'enc',
attrs: { attrs: {