Skip to content

Commit e4cd85a

Browse files
committed
feat(meta): fallback pushName from persisted contact on cloud api
1 parent b8e4bfa commit e4cd85a

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/api/integrations/channel/meta/whatsapp.business.service.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,13 @@ export class BusinessStartupService extends ChannelStartupService {
434434
if (received.messages) {
435435
const message = received.messages[0]; // Añadir esta línea para definir message
436436
const remoteJid = createJid(message?.to ?? message?.from);
437+
const contact = await this.prismaRepository.contact.findFirst({
438+
where: { instanceId: this.instanceId, remoteJid },
439+
});
440+
441+
if (!pushName) {
442+
pushName = contact?.pushName ?? incomingContact?.user_id ?? incomingContact?.wa_id ?? undefined;
443+
}
437444

438445
const key = {
439446
id: message.id,
@@ -740,10 +747,6 @@ export class BusinessStartupService extends ChannelStartupService {
740747
});
741748
}
742749

743-
const contact = await this.prismaRepository.contact.findFirst({
744-
where: { instanceId: this.instanceId, remoteJid: key.remoteJid },
745-
});
746-
747750
const contactPhone = incomingContact?.profile?.phone ?? incomingContact?.wa_id ?? message?.to ?? message?.from;
748751
if (!contactPhone) return;
749752

0 commit comments

Comments
 (0)