From 2c76098d59d743bb9dfff03114b4fe766ffe1bf6 Mon Sep 17 00:00:00 2001 From: Pedro Howat Date: Tue, 24 Sep 2024 10:12:59 -0300 Subject: [PATCH] Insert contant without the pushName if fromMe but update it later --- src/api/services/channels/whatsapp.baileys.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/services/channels/whatsapp.baileys.service.ts b/src/api/services/channels/whatsapp.baileys.service.ts index 8a6ac130..9b823a9b 100644 --- a/src/api/services/channels/whatsapp.baileys.service.ts +++ b/src/api/services/channels/whatsapp.baileys.service.ts @@ -1227,7 +1227,7 @@ export class BaileysStartupService extends ChannelStartupService { this.logger.verbose('Contact found in database'); const contactRaw: ContactRaw = { id: received.key.remoteJid, - pushName: contact[0].pushName, + pushName: contact[0].pushName || received.pushName, profilePictureUrl: (await this.profilePicture(received.key.remoteJid)).profilePictureUrl, owner: this.instance.name, }; @@ -1255,8 +1255,10 @@ export class BaileysStartupService extends ChannelStartupService { this.logger.verbose('Inserting contact in database'); - if (received?.key?.fromMe === false) - this.repository.contact.insert([contactRaw], this.instance.name, database.SAVE_DATA.CONTACTS); + if (received?.key?.fromMe === true) { + contactRaw.pushName = null; + } + this.repository.contact.insert([contactRaw], this.instance.name, database.SAVE_DATA.CONTACTS); } } catch (error) { this.logger.error(error);