Skip to content

Commit 06b0ff0

Browse files
committed
fix(whatsapp): update chatsRaw handling to remove remoteLid and optimize variable declaration
1 parent 3979a9e commit 06b0ff0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ export class BaileysStartupService extends ChannelStartupService {
997997
contactsMapLidJid.set(contact.id, { jid });
998998
}
999999

1000-
const chatsRaw: { remoteJid: string; remoteLid: string; instanceId: string; name?: string }[] = [];
1000+
let chatsRaw: { remoteJid: string; remoteLid: string; instanceId: string; name?: string }[] = [];
10011001
const chatsRepository = new Set(
10021002
(await this.prismaRepository.chat.findMany({ where: { instanceId: this.instanceId } })).map(
10031003
(chat) => chat.remoteJid,
@@ -1032,6 +1032,12 @@ export class BaileysStartupService extends ChannelStartupService {
10321032
this.sendDataWebhook(Events.CHATS_SET, chatsRaw);
10331033

10341034
if (this.configService.get<Database>('DATABASE').SAVE_DATA.HISTORIC) {
1035+
chatsRaw = chatsRaw.map((chat) => {
1036+
delete chat.remoteLid;
1037+
1038+
return chat;
1039+
});
1040+
10351041
await this.prismaRepository.chat.createMany({ data: chatsRaw, skipDuplicates: true });
10361042
}
10371043

0 commit comments

Comments
 (0)