fix(whatsapp): prevent merged lid conversations from returning

This commit is contained in:
wmq
2026-08-03 01:35:44 +08:00
parent 9017c26f5b
commit 48d719e520
4 changed files with 59 additions and 5 deletions
+9
View File
@@ -3,6 +3,7 @@ import test from 'node:test'
import {
canonicalWhatsAppJid,
isWeakWhatsAppDisplayName,
resolvedWhatsAppJid,
reusableWhatsAppConversations,
whatsappCustomerStableId,
} from '../src/whatsapp-identity.js'
@@ -16,6 +17,14 @@ test('WhatsApp LID resolves to the same canonical phone identity', () => {
assert.equal(canonicalWhatsAppJid('987654321@lid', { canonicalJid: '15551234567:0@s.whatsapp.net' }), phoneJid)
})
test('a newly resolved phone identity overrides a stale cached LID', () => {
const lid = '987654321@lid'
const phoneJid = '15551234567@s.whatsapp.net'
assert.equal(resolvedWhatsAppJid(lid, {}, lid), lid)
assert.equal(resolvedWhatsAppJid(lid, { phone: '+1 555 123 4567' }, lid), phoneJid)
assert.equal(resolvedWhatsAppJid(lid, {}, phoneJid), phoneJid)
})
test('WhatsApp customer id remains stable after gateway reauthorization', () => {
assert.equal(
whatsappCustomerStableId('15551234567@s.whatsapp.net'),