fix(whatsapp): update chatsRaw handling to remove remoteLid and optimize variable declaration

This commit is contained in:
Jeferson Ramos
2026-01-20 13:14:46 -03:00
parent 3979a9e08c
commit 06b0ff0e27
@@ -997,7 +997,7 @@ export class BaileysStartupService extends ChannelStartupService {
contactsMapLidJid.set(contact.id, { jid });
}
const chatsRaw: { remoteJid: string; remoteLid: string; instanceId: string; name?: string }[] = [];
let chatsRaw: { remoteJid: string; remoteLid: string; instanceId: string; name?: string }[] = [];
const chatsRepository = new Set(
(await this.prismaRepository.chat.findMany({ where: { instanceId: this.instanceId } })).map(
(chat) => chat.remoteJid,
@@ -1032,6 +1032,12 @@ export class BaileysStartupService extends ChannelStartupService {
this.sendDataWebhook(Events.CHATS_SET, chatsRaw);
if (this.configService.get<Database>('DATABASE').SAVE_DATA.HISTORIC) {
chatsRaw = chatsRaw.map((chat) => {
delete chat.remoteLid;
return chat;
});
await this.prismaRepository.chat.createMany({ data: chatsRaw, skipDuplicates: true });
}