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 @@ -1147,9 +1147,14 @@ export class BaileysStartupService extends ChannelStartupService {
11471147
11481148 this . sendDataWebhook ( Events . CHATS_UPSERT , [ chatToInsert ] ) ;
11491149 if ( this . configService . get < Database > ( 'DATABASE' ) . SAVE_DATA . CHATS ) {
1150- await this . prismaRepository . chat . create ( {
1151- data : chatToInsert ,
1152- } ) ;
1150+ try {
1151+ await this . prismaRepository . chat . create ( {
1152+ data : chatToInsert ,
1153+ } ) ;
1154+ }
1155+ catch ( error ) {
1156+ console . log ( `Chat insert record ignored: ${ chatToInsert . remoteJid } - ${ chatToInsert . instanceId } ` ) ;
1157+ }
11531158 }
11541159 }
11551160
@@ -1483,9 +1488,14 @@ export class BaileysStartupService extends ChannelStartupService {
14831488
14841489 this . sendDataWebhook ( Events . CHATS_UPSERT , [ chatToInsert ] ) ;
14851490 if ( this . configService . get < Database > ( 'DATABASE' ) . SAVE_DATA . CHATS ) {
1486- await this . prismaRepository . chat . create ( {
1487- data : chatToInsert ,
1488- } ) ;
1491+ try {
1492+ await this . prismaRepository . chat . create ( {
1493+ data : chatToInsert ,
1494+ } ) ;
1495+ }
1496+ catch ( error ) {
1497+ console . log ( `Chat insert record ignored: ${ chatToInsert . remoteJid } - ${ chatToInsert . instanceId } ` ) ;
1498+ }
14891499 }
14901500 }
14911501 }
You can’t perform that action at this time.
0 commit comments