From ca2387cc70a5e3c377bc4a821351584d6d1c0b65 Mon Sep 17 00:00:00 2001 From: Andre Fontana Date: Fri, 27 Sep 2024 14:49:58 -0300 Subject: [PATCH 1/3] Adjust contact pushName. Not save when in message.upsert and the pushName is from the instance name --- .../channel/evolution/evolution.channel.service.ts | 2 +- .../integrations/channel/whatsapp/whatsapp.baileys.service.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/integrations/channel/evolution/evolution.channel.service.ts b/src/api/integrations/channel/evolution/evolution.channel.service.ts index 4c278668..0fda0214 100644 --- a/src/api/integrations/channel/evolution/evolution.channel.service.ts +++ b/src/api/integrations/channel/evolution/evolution.channel.service.ts @@ -164,7 +164,7 @@ export class EvolutionStartupService extends ChannelStartupService { await this.updateContact({ remoteJid: messageRaw.key.remoteJid, - pushName: messageRaw.pushName, + pushName: messageRaw.key.fromMe ? '' : (messageRaw.key.fromMe == null ? '' : messageRaw.pushName), profilePicUrl: received.profilePicUrl, }); } diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 13eea7b5..0071fe3f 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -1179,7 +1179,7 @@ export class BaileysStartupService extends ChannelStartupService { const contactRaw: { remoteJid: string; pushName: string; profilePicUrl?: string; instanceId: string } = { remoteJid: received.key.remoteJid, - pushName: received.pushName, + pushName: received.key.fromMe ? '' : (received.key.fromMe == null ? '' : contact.pushName), profilePicUrl: (await this.profilePicture(received.key.remoteJid)).profilePictureUrl, instanceId: this.instanceId, }; @@ -1191,7 +1191,7 @@ export class BaileysStartupService extends ChannelStartupService { if (contact) { const contactRaw: { remoteJid: string; pushName: string; profilePicUrl?: string; instanceId: string } = { remoteJid: received.key.remoteJid, - pushName: contact.pushName, + pushName: received.key.fromMe ? '' : (received.key.fromMe == null ? '' : contact.pushName), profilePicUrl: (await this.profilePicture(received.key.remoteJid)).profilePictureUrl, instanceId: this.instanceId, }; From 1e5d62c777e1ca78e46188216275f0ccf690e309 Mon Sep 17 00:00:00 2001 From: Andre Fontana Date: Fri, 27 Sep 2024 15:01:35 -0300 Subject: [PATCH 2/3] Adjust contact pushName. Not save when in message.upsert and the pushName is from the instance name --- .../channel/whatsapp/whatsapp.baileys.service.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 0071fe3f..20b287d6 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -1179,7 +1179,7 @@ export class BaileysStartupService extends ChannelStartupService { const contactRaw: { remoteJid: string; pushName: string; profilePicUrl?: string; instanceId: string } = { remoteJid: received.key.remoteJid, - pushName: received.key.fromMe ? '' : (received.key.fromMe == null ? '' : contact.pushName), + pushName: received.key.fromMe ? '' : (received.key.fromMe == null ? '' : received.pushName), profilePicUrl: (await this.profilePicture(received.key.remoteJid)).profilePictureUrl, instanceId: this.instanceId, }; @@ -1189,13 +1189,6 @@ export class BaileysStartupService extends ChannelStartupService { } if (contact) { - const contactRaw: { remoteJid: string; pushName: string; profilePicUrl?: string; instanceId: string } = { - remoteJid: received.key.remoteJid, - pushName: received.key.fromMe ? '' : (received.key.fromMe == null ? '' : contact.pushName), - profilePicUrl: (await this.profilePicture(received.key.remoteJid)).profilePictureUrl, - instanceId: this.instanceId, - }; - this.sendDataWebhook(Events.CONTACTS_UPDATE, contactRaw); if (this.configService.get('CHATWOOT').ENABLED && this.localChatwoot?.enabled) { From 510eaf11415577eb25dc0caea08512766e5ff6f3 Mon Sep 17 00:00:00 2001 From: Andre Fontana Date: Fri, 27 Sep 2024 15:03:17 -0300 Subject: [PATCH 3/3] Adjust contact pushName. Not save when in message.upsert and the pushName is from the instance name --- .../integrations/channel/evolution/evolution.channel.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/integrations/channel/evolution/evolution.channel.service.ts b/src/api/integrations/channel/evolution/evolution.channel.service.ts index 0fda0214..1c61e746 100644 --- a/src/api/integrations/channel/evolution/evolution.channel.service.ts +++ b/src/api/integrations/channel/evolution/evolution.channel.service.ts @@ -164,7 +164,7 @@ export class EvolutionStartupService extends ChannelStartupService { await this.updateContact({ remoteJid: messageRaw.key.remoteJid, - pushName: messageRaw.key.fromMe ? '' : (messageRaw.key.fromMe == null ? '' : messageRaw.pushName), + pushName: messageRaw.key.fromMe ? '' : (messageRaw.key.fromMe == null ? '' : received.pushName), profilePicUrl: received.profilePicUrl, }); }