Skip to content

Commit 8c6f95f

Browse files
committed
Fixing chatname on the events message.upsert and message.update in order to return always the chatname from the user correctly
1 parent 402b37d commit 8c6f95f

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export class BaileysStartupService extends ChannelStartupService {
382382
qrcodeTerminal.generate(qr, { small: true }, (qrcode) =>
383383
this.logger.log(
384384
`\n{ instance: ${this.instance.name} pairingCode: ${this.instance.qrcode.pairingCode}, qrcodeCount: ${this.instance.qrcode.count} }\n` +
385-
qrcode,
385+
qrcode,
386386
),
387387
);
388388

@@ -1023,18 +1023,18 @@ export class BaileysStartupService extends ChannelStartupService {
10231023

10241024
const messagesRepository: Set<string> = new Set(
10251025
chatwootImport.getRepositoryMessagesCache(instance) ??
1026-
(
1027-
await this.prismaRepository.message.findMany({
1028-
select: { key: true },
1029-
where: { instanceId: this.instanceId },
1030-
})
1031-
).map((message) => {
1032-
const key = message.key as {
1033-
id: string;
1034-
};
1035-
1036-
return key.id;
1037-
}),
1026+
(
1027+
await this.prismaRepository.message.findMany({
1028+
select: { key: true },
1029+
where: { instanceId: this.instanceId },
1030+
})
1031+
).map((message) => {
1032+
const key = message.key as {
1033+
id: string;
1034+
};
1035+
1036+
return key.id;
1037+
}),
10381038
);
10391039

10401040
if (chatwootImport.getRepositoryMessagesCache(instance) === null) {
@@ -1226,6 +1226,7 @@ export class BaileysStartupService extends ChannelStartupService {
12261226
received.pushName &&
12271227
existingChat.name !== received.pushName &&
12281228
received.pushName.trim().length > 0 &&
1229+
!received.key.fromMe &&
12291230
!received.key.remoteJid.includes('@g.us')
12301231
) {
12311232
this.sendDataWebhook(Events.CHATS_UPSERT, [{ ...existingChat, name: received.pushName }]);
@@ -1585,7 +1586,6 @@ export class BaileysStartupService extends ChannelStartupService {
15851586
const chatToInsert = {
15861587
remoteJid: message.remoteJid,
15871588
instanceId: this.instanceId,
1588-
name: message.pushName || '',
15891589
unreadMessages: 0,
15901590
};
15911591

0 commit comments

Comments
 (0)