File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
src/api/integrations/channel/whatsapp Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ model Chat {
127127 unreadMessages Int @default (0 )
128128 @@index ([instanceId ] )
129129 @@index ([remoteJid ] )
130+ @@unique ([instanceId , remoteJid ] )
130131}
131132
132133model Contact {
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ model Chat {
127127 unreadMessages Int @default (0 )
128128 @@index ([instanceId ] )
129129 @@index ([remoteJid ] )
130+ @@unique ([remoteJid , instanceId ] )
130131}
131132
132133model Contact {
Original file line number Diff line number Diff line change @@ -1085,9 +1085,14 @@ export class BaileysStartupService extends ChannelStartupService {
10851085
10861086 this . sendDataWebhook ( Events . CHATS_UPSERT , [ chatToInsert ] ) ;
10871087 if ( this . configService . get < Database > ( 'DATABASE' ) . SAVE_DATA . CHATS ) {
1088- await this . prismaRepository . chat . create ( {
1089- data : chatToInsert ,
1090- } ) ;
1088+ try {
1089+ await this . prismaRepository . chat . create ( {
1090+ data : chatToInsert ,
1091+ } ) ;
1092+ }
1093+ catch ( error ) {
1094+ console . log ( `Chat insert record ignored: ${ chatToInsert . remoteJid } - ${ chatToInsert . instanceId } ` ) ;
1095+ }
10911096 }
10921097 }
10931098
@@ -1420,9 +1425,14 @@ export class BaileysStartupService extends ChannelStartupService {
14201425
14211426 this . sendDataWebhook ( Events . CHATS_UPSERT , [ chatToInsert ] ) ;
14221427 if ( this . configService . get < Database > ( 'DATABASE' ) . SAVE_DATA . CHATS ) {
1423- await this . prismaRepository . chat . create ( {
1424- data : chatToInsert ,
1425- } ) ;
1428+ try {
1429+ await this . prismaRepository . chat . create ( {
1430+ data : chatToInsert ,
1431+ } ) ;
1432+ }
1433+ catch ( error ) {
1434+ console . log ( `Chat insert record ignored: ${ chatToInsert . remoteJid } - ${ chatToInsert . instanceId } ` ) ;
1435+ }
14261436 }
14271437 }
14281438 }
You can’t perform that action at this time.
0 commit comments