Fix: Actualizar nombre del chat cuando llega pushName del contacto
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m4s

This commit is contained in:
2025-12-02 20:23:31 -06:00
parent 26f755926b
commit ea5c5943df

View File

@@ -525,11 +525,13 @@ class BaileysManager extends EventEmitter {
return
}
// Ensure chat exists
// Ensure chat exists and update name if pushName is available
const chatResult = await query<{ id: string }>(
`INSERT INTO chats (instance_id, jid, name, is_group)
VALUES ($1, $2, $3, $4)
ON CONFLICT (instance_id, jid) DO UPDATE SET updated_at = NOW()
ON CONFLICT (instance_id, jid) DO UPDATE SET
name = COALESCE(NULLIF(EXCLUDED.name, chats.jid), chats.name),
updated_at = NOW()
RETURNING id`,
[instanceId, jid, msg.pushName || jid.split('@')[0], jid.includes('@g.us')]
)