mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
fix: chats must be unique
This commit is contained in:
parent
1665654676
commit
cefe3ef6c3
@ -127,6 +127,7 @@ model Chat {
|
||||
unreadMessages Int @default(0)
|
||||
@@index([instanceId])
|
||||
@@index([remoteJid])
|
||||
@@unique([remoteJid, instanceId])
|
||||
}
|
||||
|
||||
model Contact {
|
||||
|
@ -127,6 +127,7 @@ model Chat {
|
||||
unreadMessages Int @default(0)
|
||||
@@index([instanceId])
|
||||
@@index([remoteJid])
|
||||
@@unique([remoteJid, instanceId])
|
||||
}
|
||||
|
||||
model Contact {
|
||||
|
@ -1147,7 +1147,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
|
||||
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CHATS) {
|
||||
await this.prismaRepository.chat.create({
|
||||
await this.prismaRepository.chat.update({
|
||||
where: {
|
||||
id: existingChat.id,
|
||||
},
|
||||
data: chatToInsert,
|
||||
});
|
||||
}
|
||||
@ -1483,7 +1486,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
|
||||
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CHATS) {
|
||||
await this.prismaRepository.chat.create({
|
||||
await this.prismaRepository.chat.update({
|
||||
where: {
|
||||
id: existingChat.id,
|
||||
},
|
||||
data: chatToInsert,
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user