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.
This commit is contained in:
@@ -930,7 +930,11 @@ export const processSyncAction = (
|
|||||||
ev.emit('contacts.upsert', [
|
ev.emit('contacts.upsert', [
|
||||||
{
|
{
|
||||||
id: id!,
|
id: id!,
|
||||||
name: action.lidContactAction.fullName || undefined,
|
name:
|
||||||
|
action.lidContactAction.fullName ||
|
||||||
|
action.lidContactAction.firstName ||
|
||||||
|
action.lidContactAction.username ||
|
||||||
|
undefined,
|
||||||
lid: id!,
|
lid: id!,
|
||||||
phoneNumber: undefined
|
phoneNumber: undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export const processContactAction = (
|
|||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
id,
|
id,
|
||||||
name: action.fullName || undefined,
|
name: action.fullName || action.firstName || action.username || undefined,
|
||||||
lid: lidJid || undefined,
|
lid: lidJid || undefined,
|
||||||
phoneNumber
|
phoneNumber
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { jest } from '@jest/globals'
|
|||||||
import type { ILogger } from '../../Utils/logger'
|
import type { ILogger } from '../../Utils/logger'
|
||||||
import { processContactAction } from '../../Utils/sync-action-utils'
|
import { processContactAction } from '../../Utils/sync-action-utils'
|
||||||
|
|
||||||
|
|
||||||
describe('processContactAction', () => {
|
describe('processContactAction', () => {
|
||||||
const mockLogger: ILogger = {
|
const mockLogger: ILogger = {
|
||||||
warn: jest.fn(),
|
warn: jest.fn(),
|
||||||
|
|||||||
Reference in New Issue
Block a user