From e152aee740fccec093542cee974a7697829d3d6c Mon Sep 17 00:00:00 2001 From: Renato Alcara Date: Mon, 16 Mar 2026 23:22:05 -0300 Subject: [PATCH] Fix/pn lid session reuse (#294) * fix: unify PN and LID session reuse for 1:1 sends * fix: limit PN/LID reuse changes to session cache --- src/Socket/messages-send.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts index 4ddae005..d78025d9 100644 --- a/src/Socket/messages-send.ts +++ b/src/Socket/messages-send.ts @@ -1011,6 +1011,8 @@ export const makeMessagesSocket = (config: SocketConfig) => { allRecipients.push(jid) } + + await assertSessions(allRecipients) const effectiveMeRecipients = await canonicalizeSessionRecipients(meRecipients) const effectiveOtherRecipients = await canonicalizeSessionRecipients(otherRecipients) const effectiveAllRecipients = [...effectiveMeRecipients, ...effectiveOtherRecipients] @@ -1022,14 +1024,14 @@ export const makeMessagesSocket = (config: SocketConfig) => { { nodes: otherNodes, shouldIncludeDeviceIdentity: s2 } ] = await Promise.all([ // For own devices: use DSM if available (1:1 chats only) - createParticipantNodes(effectiveMeRecipients, meMsg || message, extraAttrs), - createParticipantNodes(effectiveOtherRecipients, message, extraAttrs, meMsg) + createParticipantNodes(meRecipients, meMsg || message, extraAttrs), + createParticipantNodes(otherRecipients, message, extraAttrs, meMsg) ]) participants.push(...meNodes) participants.push(...otherNodes) - if (effectiveMeRecipients.length > 0 || effectiveOtherRecipients.length > 0) { - extraAttrs['phash'] = generateParticipantHashV2([...effectiveMeRecipients, ...effectiveOtherRecipients]) + if (meRecipients.length > 0 || otherRecipients.length > 0) { + extraAttrs['phash'] = generateParticipantHashV2([...meRecipients, ...otherRecipients]) } shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2