@@ -30,6 +30,7 @@ import makeWASocket, {
3030 WAMessageUpdate ,
3131 WASocket ,
3232 getAggregateVotesInPollMessage ,
33+ Browsers ,
3334} from '@whiskeysockets/baileys' ;
3435import {
3536 Auth ,
@@ -554,14 +555,14 @@ export class WAStartupService {
554555 `rm -rf ${ join (
555556 this . storePath ,
556557 key . toLowerCase ( ) . replace ( '_' , '-' ) ,
557- this . instance . wuid ,
558+ this . instance . name ,
558559 ) } /*.json`,
559560 ) ;
560561 this . logger . verbose (
561562 `Cleaned ${ join (
562563 this . storePath ,
563564 key . toLowerCase ( ) . replace ( '_' , '-' ) ,
564- this . instance . wuid ,
565+ this . instance . name ,
565566 ) } /*.json`,
566567 ) ;
567568 }
@@ -601,7 +602,8 @@ export class WAStartupService {
601602 const { version } = await fetchLatestBaileysVersion ( ) ;
602603 this . logger . verbose ( 'Baileys version: ' + version ) ;
603604 const session = this . configService . get < ConfigSessionPhone > ( 'CONFIG_SESSION_PHONE' ) ;
604- const browser : WABrowserDescription = [ session . CLIENT , session . NAME , release ( ) ] ;
605+ // const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
606+ const browser : WABrowserDescription = Browsers . appropriate ( session . CLIENT ) ;
605607 this . logger . verbose ( 'Browser: ' + JSON . stringify ( browser ) ) ;
606608
607609 const socketConfig : UserFacingSocketConfig = {
@@ -692,7 +694,11 @@ export class WAStartupService {
692694 await this . sendDataWebhook ( Events . CHATS_UPSERT , chatsRaw ) ;
693695
694696 this . logger . verbose ( 'Inserting chats in database' ) ;
695- await this . repository . chat . insert ( chatsRaw , database . SAVE_DATA . CHATS ) ;
697+ await this . repository . chat . insert (
698+ chatsRaw ,
699+ this . instance . name ,
700+ database . SAVE_DATA . CHATS ,
701+ ) ;
696702 } ,
697703
698704 'chats.update' : async (
@@ -757,7 +763,11 @@ export class WAStartupService {
757763 await this . sendDataWebhook ( Events . CONTACTS_UPSERT , contactsRaw ) ;
758764
759765 this . logger . verbose ( 'Inserting contacts in database' ) ;
760- await this . repository . contact . insert ( contactsRaw , database . SAVE_DATA . CONTACTS ) ;
766+ await this . repository . contact . insert (
767+ contactsRaw ,
768+ this . instance . name ,
769+ database . SAVE_DATA . CONTACTS ,
770+ ) ;
761771 } ,
762772
763773 'contacts.update' : async ( contacts : Partial < Contact > [ ] ) => {
@@ -808,7 +818,11 @@ export class WAStartupService {
808818 await this . sendDataWebhook ( Events . CHATS_SET , chatsRaw ) ;
809819
810820 this . logger . verbose ( 'Inserting chats in database' ) ;
811- await this . repository . chat . insert ( chatsRaw , database . SAVE_DATA . CHATS ) ;
821+ await this . repository . chat . insert (
822+ chatsRaw ,
823+ this . instance . name ,
824+ database . SAVE_DATA . CHATS ,
825+ ) ;
812826 }
813827
814828 const messagesRaw : MessageRaw [ ] = [ ] ;
@@ -890,7 +904,11 @@ export class WAStartupService {
890904 await this . sendDataWebhook ( Events . MESSAGES_UPSERT , messageRaw ) ;
891905
892906 this . logger . verbose ( 'Inserting message in database' ) ;
893- await this . repository . message . insert ( [ messageRaw ] , database . SAVE_DATA . NEW_MESSAGE ) ;
907+ await this . repository . message . insert (
908+ [ messageRaw ] ,
909+ this . instance . name ,
910+ database . SAVE_DATA . NEW_MESSAGE ,
911+ ) ;
894912 } ,
895913
896914 'messages.update' : async ( args : WAMessageUpdate [ ] , database : Database ) => {
@@ -934,6 +952,7 @@ export class WAStartupService {
934952 this . logger . verbose ( 'Inserting message in database' ) ;
935953 await this . repository . messageUpdate . insert (
936954 [ message ] ,
955+ this . instance . name ,
937956 database . SAVE_DATA . MESSAGE_UPDATE ,
938957 ) ;
939958 }
0 commit comments