From fe9a3166a89340d3a8afc4734f6fd6d9091a79ca Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Jan 2026 20:11:20 +0000 Subject: [PATCH] chat-utils: add fallbacks for contact name extraction Apply consistent fallback pattern for contact names: - chat-utils.ts: fullName || firstName || username for lidContactAction - sync-action-utils.ts: fullName || firstName || username for processContactAction Ensures contact names are extracted regardless of which field WhatsApp populates. --- src/Utils/chat-utils.ts | 6 +++++- src/Utils/sync-action-utils.ts | 2 +- src/__tests__/Utils/sync-action-utils.test.ts | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Utils/chat-utils.ts b/src/Utils/chat-utils.ts index c03bd3c2..65f11571 100644 --- a/src/Utils/chat-utils.ts +++ b/src/Utils/chat-utils.ts @@ -930,7 +930,11 @@ export const processSyncAction = ( ev.emit('contacts.upsert', [ { id: id!, - name: action.lidContactAction.fullName || undefined, + name: + action.lidContactAction.fullName || + action.lidContactAction.firstName || + action.lidContactAction.username || + undefined, lid: id!, phoneNumber: undefined } diff --git a/src/Utils/sync-action-utils.ts b/src/Utils/sync-action-utils.ts index d53b00fb..14ecd310 100644 --- a/src/Utils/sync-action-utils.ts +++ b/src/Utils/sync-action-utils.ts @@ -45,7 +45,7 @@ export const processContactAction = ( data: [ { id, - name: action.fullName || undefined, + name: action.fullName || action.firstName || action.username || undefined, lid: lidJid || undefined, phoneNumber } diff --git a/src/__tests__/Utils/sync-action-utils.test.ts b/src/__tests__/Utils/sync-action-utils.test.ts index 5c19d29e..fbf54303 100644 --- a/src/__tests__/Utils/sync-action-utils.test.ts +++ b/src/__tests__/Utils/sync-action-utils.test.ts @@ -2,7 +2,6 @@ import { jest } from '@jest/globals' import type { ILogger } from '../../Utils/logger' import { processContactAction } from '../../Utils/sync-action-utils' - describe('processContactAction', () => { const mockLogger: ILogger = { warn: jest.fn(),