mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
Merge pull request #1012 from yousseefspires/fix/chats-messages
Add unique in Chat by instance/remotejid
This commit is contained in:
commit
d5a7e03ec2
@ -127,6 +127,7 @@ model Chat {
|
||||
unreadMessages Int @default(0)
|
||||
@@index([instanceId])
|
||||
@@index([remoteJid])
|
||||
@@unique([instanceId, remoteJid])
|
||||
}
|
||||
|
||||
model Contact {
|
||||
|
@ -127,6 +127,7 @@ model Chat {
|
||||
unreadMessages Int @default(0)
|
||||
@@index([instanceId])
|
||||
@@index([remoteJid])
|
||||
@@unique([remoteJid, instanceId])
|
||||
}
|
||||
|
||||
model Contact {
|
||||
|
@ -1147,9 +1147,14 @@ 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({
|
||||
data: chatToInsert,
|
||||
});
|
||||
try {
|
||||
await this.prismaRepository.chat.create({
|
||||
data: chatToInsert,
|
||||
});
|
||||
}
|
||||
catch(error){
|
||||
console.log(`Chat insert record ignored: ${chatToInsert.remoteJid} - ${chatToInsert.instanceId}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1483,9 +1488,14 @@ 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({
|
||||
data: chatToInsert,
|
||||
});
|
||||
try {
|
||||
await this.prismaRepository.chat.create({
|
||||
data: chatToInsert,
|
||||
});
|
||||
}
|
||||
catch(error){
|
||||
console.log(`Chat insert record ignored: ${chatToInsert.remoteJid} - ${chatToInsert.instanceId}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user