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 {
127
127
unreadMessages Int @default (0 )
128
128
@@index ([instanceId ] )
129
129
@@index ([remoteJid ] )
130
+ @@unique ([instanceId , remoteJid ] )
130
131
}
131
132
132
133
model Contact {
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ model Chat {
127
127
unreadMessages Int @default (0 )
128
128
@@index ([instanceId ] )
129
129
@@index ([remoteJid ] )
130
+ @@unique ([remoteJid , instanceId ] )
130
131
}
131
132
132
133
model Contact {
Original file line number Diff line number Diff line change @@ -1147,9 +1147,14 @@ export class BaileysStartupService extends ChannelStartupService {
1147
1147
1148
1148
this . sendDataWebhook ( Events . CHATS_UPSERT , [ chatToInsert ] ) ;
1149
1149
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
+ }
1153
1158
}
1154
1159
}
1155
1160
@@ -1483,9 +1488,14 @@ export class BaileysStartupService extends ChannelStartupService {
1483
1488
1484
1489
this . sendDataWebhook ( Events . CHATS_UPSERT , [ chatToInsert ] ) ;
1485
1490
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
+ }
1489
1499
}
1490
1500
}
1491
1501
}
You can’t perform that action at this time.
0 commit comments