fix(whatsapp): unify contact identity and reduce realtime latency

This commit is contained in:
wmq
2026-08-03 00:54:59 +08:00
parent bb696c7de8
commit 7e739ad7b8
11 changed files with 280 additions and 75 deletions
+8
View File
@@ -1,11 +1,19 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import {
canonicalWhatsAppJid,
isWeakWhatsAppDisplayName,
reusableWhatsAppConversations,
whatsappCustomerStableId,
} from '../src/whatsapp-identity.js'
test('WhatsApp LID resolves to the same canonical phone identity', () => {
const phoneJid = '15551234567@s.whatsapp.net'
assert.equal(canonicalWhatsAppJid('987654321@lid', { phone: '+1 555 123 4567' }), phoneJid)
assert.equal(canonicalWhatsAppJid('987654321@lid', { canonicalJid: phoneJid }), phoneJid)
assert.equal(whatsappCustomerStableId(canonicalWhatsAppJid('987654321@lid', { phone: '+1 555 123 4567' })), whatsappCustomerStableId(phoneJid))
})
test('WhatsApp customer id remains stable after gateway reauthorization', () => {
assert.equal(
whatsappCustomerStableId('15551234567@s.whatsapp.net'),