@@ -328,7 +328,7 @@ export class WAStartupService {
328328
329329 if ( ! data ) {
330330 this . logger . verbose ( 'Chatwoot not found' ) ;
331- throw new NotFoundException ( 'Chatwoot not found' ) ;
331+ return null ;
332332 }
333333
334334 this . logger . verbose ( `Chatwoot account id: ${ data . account_id } ` ) ;
@@ -351,7 +351,7 @@ export class WAStartupService {
351351 const expose =
352352 this . configService . get < Auth > ( 'AUTHENTICATION' ) . EXPOSE_IN_FETCH_INSTANCES ;
353353 const tokenStore = await this . repository . auth . find ( this . instanceName ) ;
354- const instanceApikey = tokenStore . apikey || 'Apikey not found' ;
354+ const instanceApikey = tokenStore ? .apikey || 'Apikey not found' ;
355355
356356 const globalApiKey = this . configService . get < Auth > ( 'AUTHENTICATION' ) . API_KEY . KEY ;
357357
@@ -1190,6 +1190,22 @@ export class WAStartupService {
11901190
11911191 this . logger . verbose ( 'Sending data to webhook in event MESSAGE_DELETE' ) ;
11921192 await this . sendDataWebhook ( Events . MESSAGES_DELETE , key ) ;
1193+
1194+ const message : MessageUpdateRaw = {
1195+ ...key ,
1196+ status : 'DELETED' ,
1197+ datetime : Date . now ( ) ,
1198+ owner : this . instance . name ,
1199+ } ;
1200+
1201+ this . logger . verbose ( message ) ;
1202+
1203+ this . logger . verbose ( 'Inserting message in database' ) ;
1204+ await this . repository . messageUpdate . insert (
1205+ [ message ] ,
1206+ this . instance . name ,
1207+ database . SAVE_DATA . MESSAGE_UPDATE ,
1208+ ) ;
11931209 return ;
11941210 }
11951211
@@ -2351,6 +2367,9 @@ export class WAStartupService {
23512367 this . logger . verbose ( 'Fetching contacts' ) ;
23522368 if ( query ?. where ) {
23532369 query . where . owner = this . instance . name ;
2370+ if ( query . where ?. id ) {
2371+ query . where . id = this . createJid ( query . where . id ) ;
2372+ }
23542373 } else {
23552374 query = {
23562375 where : {
0 commit comments