@@ -82,7 +82,7 @@ import { createId as cuid } from '@paralleldrive/cuid2';
8282import { Instance , Message } from '@prisma/client' ;
8383import { createJid } from '@utils/createJid' ;
8484import { fetchLatestWaWebVersion } from '@utils/fetchLatestWaWebVersion' ;
85- import { makeProxyAgent , makeProxyAgentUndici } from '@utils/makeProxyAgent' ;
85+ import { makeProxyAgent , makeProxyAgentUndici } from '@utils/makeProxyAgent' ;
8686import { getOnWhatsappCache , saveOnWhatsappCache } from '@utils/onWhatsappCache' ;
8787import { status } from '@utils/renderStatus' ;
8888import { sendTelemetry } from '@utils/sendTelemetry' ;
@@ -380,7 +380,7 @@ export class BaileysStartupService extends ChannelStartupService {
380380 qrcodeTerminal . generate ( qr , { small : true } , ( qrcode ) =>
381381 this . logger . log (
382382 `\n{ instance: ${ this . instance . name } pairingCode: ${ this . instance . qrcode . pairingCode } , qrcodeCount: ${ this . instance . qrcode . count } }\n` +
383- qrcode ,
383+ qrcode ,
384384 ) ,
385385 ) ;
386386
@@ -839,10 +839,14 @@ export class BaileysStartupService extends ChannelStartupService {
839839 this . sendDataWebhook ( Events . CONTACTS_UPDATE , updatedContacts ) ;
840840 await Promise . all (
841841 updatedContacts . map ( async ( contact ) => {
842- const update = this . prismaRepository . contact . updateMany ( {
843- where : { remoteJid : contact . remoteJid , instanceId : this . instanceId } ,
844- data : { profilePicUrl : contact . profilePicUrl } ,
845- } ) ;
842+ let update ;
843+ if ( this . configService . get < Database > ( 'DATABASE' ) . SAVE_DATA . CONTACTS ) {
844+ update = this . prismaRepository . contact . updateMany ( {
845+ where : { remoteJid : contact . remoteJid , instanceId : this . instanceId } ,
846+ data : { profilePicUrl : contact . profilePicUrl } ,
847+ } ) ;
848+ }
849+
846850
847851 if ( this . configService . get < Chatwoot > ( 'CHATWOOT' ) . ENABLED && this . localChatwoot ?. enabled ) {
848852 const instance = { instanceName : this . instance . name , instanceId : this . instance . id } ;
@@ -886,14 +890,17 @@ export class BaileysStartupService extends ChannelStartupService {
886890
887891 this . sendDataWebhook ( Events . CONTACTS_UPDATE , contactsRaw ) ;
888892
889- const updateTransactions = contactsRaw . map ( ( contact ) =>
890- this . prismaRepository . contact . upsert ( {
891- where : { remoteJid_instanceId : { remoteJid : contact . remoteJid , instanceId : contact . instanceId } } ,
892- create : contact ,
893- update : contact ,
894- } ) ,
895- ) ;
896- await this . prismaRepository . $transaction ( updateTransactions ) ;
893+ if ( this . configService . get < Database > ( 'DATABASE' ) . SAVE_DATA . CONTACTS ) {
894+ const updateTransactions = contactsRaw . map ( ( contact ) =>
895+ this . prismaRepository . contact . upsert ( {
896+ where : { remoteJid_instanceId : { remoteJid : contact . remoteJid , instanceId : contact . instanceId } } ,
897+ create : contact ,
898+ update : contact ,
899+ } ) ,
900+ ) ;
901+ await this . prismaRepository . $transaction ( updateTransactions ) ;
902+ }
903+
897904
898905 //const usersContacts = contactsRaw.filter((c) => c.remoteJid.includes('@s.whatsapp'));
899906 } ,
@@ -975,16 +982,16 @@ export class BaileysStartupService extends ChannelStartupService {
975982
976983 const messagesRepository : Set < string > = new Set (
977984 chatwootImport . getRepositoryMessagesCache ( instance ) ??
978- (
979- await this . prismaRepository . message . findMany ( {
980- select : { key : true } ,
981- where : { instanceId : this . instanceId } ,
982- } )
983- ) . map ( ( message ) => {
984- const key = message . key as { id : string } ;
985-
986- return key . id ;
987- } ) ,
985+ (
986+ await this . prismaRepository . message . findMany ( {
987+ select : { key : true } ,
988+ where : { instanceId : this . instanceId } ,
989+ } )
990+ ) . map ( ( message ) => {
991+ const key = message . key as { id : string } ;
992+
993+ return key . id ;
994+ } ) ,
988995 ) ;
989996
990997 if ( chatwootImport . getRepositoryMessagesCache ( instance ) === null ) {
0 commit comments