feat(signal): better parity with whatsapp web (#1967)

This commit is contained in:
vini
2025-11-19 10:20:49 -03:00
committed by GitHub
parent 3be21f8b99
commit a70e4da1c4
3 changed files with 78 additions and 11 deletions
+15 -3
View File
@@ -108,6 +108,9 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
useClones: false
})
// Debounce identity-change session refreshes per JID to avoid bursts
const identityAssertDebounce = new NodeCache<boolean>({ stdTTL: 5, useClones: false })
let sendActiveReceipts = false
const fetchMessageHistory = async (
@@ -546,8 +549,17 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
const identityNode = getBinaryNodeChild(node, 'identity')
if (identityNode) {
logger.info({ jid: from }, 'identity changed')
// not handling right now
// signal will override new identity anyway
if (identityAssertDebounce.get(from!)) {
logger.debug({ jid: from }, 'skipping identity assert (debounced)')
return
}
identityAssertDebounce.set(from!, true)
try {
await assertSessions([from!], true)
} catch (error) {
logger.warn({ error, jid: from }, 'failed to assert sessions after identity change')
}
} else {
logger.info({ node }, 'unknown encrypt notification')
}
@@ -1007,7 +1019,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
}
}
await assertSessions([participant])
await assertSessions([participant], true)
if (isJidGroup(remoteJid)) {
await authState.keys.set({ 'sender-key-memory': { [remoteJid]: null } })