mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2026-03-21 20:18:40 -06:00
fix(whatsapp): update chatsRaw handling to remove remoteLid and optimize variable declaration
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user