From 1dfdd47a123c5c1f9aef9fcebd8b1c388af7ec0e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Jan 2026 19:48:20 +0000 Subject: [PATCH] feat(history): fortify contact data extraction with fallbacks - Add fallback chain for contact name: displayName || name || username - Add fallback for LID: lidJid || accountLid - Add TODO marker for WAJIDHASH support in picture updates These fallbacks improve robustness when WhatsApp returns contact data in different fields depending on account type (business, personal). --- src/Socket/messages-recv.ts | 1 + src/Utils/history.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index fb9e64d2..2b80230d 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -765,6 +765,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { const setPicture = getBinaryNodeChild(node, 'set') const delPicture = getBinaryNodeChild(node, 'delete') + // TODO: WAJIDHASH stuff proper support inhouse ev.emit('contacts.update', [ { id: jidNormalizedUser(node?.attrs?.from) || (setPicture || delPicture)?.attrs?.hash || '', diff --git a/src/Utils/history.ts b/src/Utils/history.ts index 4f1dac6e..df174892 100644 --- a/src/Utils/history.ts +++ b/src/Utils/history.ts @@ -326,8 +326,8 @@ export const processHistoryMessage = (item: proto.IHistorySync, logger?: ILogger contacts.push({ id: chatId, - name: chat.name || undefined, - lid: chat.lidJid || undefined, + name: chat.displayName || chat.name || chat.username || undefined, + lid: chat.lidJid || chat.accountLid || undefined, phoneNumber: chat.pnJid || undefined })