mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 04:02:54 -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)
|
unreadMessages Int @default(0)
|
||||||
@@index([instanceId])
|
@@index([instanceId])
|
||||||
@@index([remoteJid])
|
@@index([remoteJid])
|
||||||
|
@@unique([remoteJid, instanceId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Contact {
|
model Contact {
|
||||||
|
@ -127,6 +127,7 @@ model Chat {
|
|||||||
unreadMessages Int @default(0)
|
unreadMessages Int @default(0)
|
||||||
@@index([instanceId])
|
@@index([instanceId])
|
||||||
@@index([remoteJid])
|
@@index([remoteJid])
|
||||||
|
@@unique([remoteJid, instanceId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Contact {
|
model Contact {
|
||||||
|
@ -1147,7 +1147,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
|
this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
|
||||||
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CHATS) {
|
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,
|
data: chatToInsert,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1483,7 +1486,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
|
this.sendDataWebhook(Events.CHATS_UPSERT, [chatToInsert]);
|
||||||
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CHATS) {
|
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,
|
data: chatToInsert,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user