@@ -78,6 +78,7 @@ import ffmpegPath from '@ffmpeg-installer/ffmpeg';
7878import { Boom } from '@hapi/boom' ;
7979import { createId as cuid } from '@paralleldrive/cuid2' ;
8080import { Instance } from '@prisma/client' ;
81+ import { createJid } from '@utils/createJid' ;
8182import { makeProxyAgent } from '@utils/makeProxyAgent' ;
8283import { getOnWhatsappCache , saveOnWhatsappCache } from '@utils/onWhatsappCache' ;
8384import { status } from '@utils/renderStatus' ;
@@ -1323,17 +1324,21 @@ export class BaileysStartupService extends ChannelStartupService {
13231324
13241325 if ( this . localWebhook . enabled ) {
13251326 if ( isMedia && this . localWebhook . webhookBase64 ) {
1326- const buffer = await downloadMediaMessage (
1327- { key : received . key , message : received ?. message } ,
1328- 'buffer' ,
1329- { } ,
1330- {
1331- logger : P ( { level : 'error' } ) as any ,
1332- reuploadRequest : this . client . updateMediaMessage ,
1333- } ,
1334- ) ;
1327+ try {
1328+ const buffer = await downloadMediaMessage (
1329+ { key : received . key , message : received ?. message } ,
1330+ 'buffer' ,
1331+ { } ,
1332+ {
1333+ logger : P ( { level : 'error' } ) as any ,
1334+ reuploadRequest : this . client . updateMediaMessage ,
1335+ } ,
1336+ ) ;
13351337
1336- messageRaw . message . base64 = buffer ? buffer . toString ( 'base64' ) : undefined ;
1338+ messageRaw . message . base64 = buffer ? buffer . toString ( 'base64' ) : undefined ;
1339+ } catch ( error ) {
1340+ this . logger . error ( [ 'Error converting media to base64' , error ?. message ] ) ;
1341+ }
13371342 }
13381343 }
13391344
@@ -1809,7 +1814,7 @@ export class BaileysStartupService extends ChannelStartupService {
18091814 }
18101815
18111816 public async profilePicture ( number : string ) {
1812- const jid = this . createJid ( number ) ;
1817+ const jid = createJid ( number ) ;
18131818
18141819 try {
18151820 const profilePictureUrl = await this . client . profilePictureUrl ( jid , 'image' ) ;
@@ -1827,7 +1832,7 @@ export class BaileysStartupService extends ChannelStartupService {
18271832 }
18281833
18291834 public async getStatus ( number : string ) {
1830- const jid = this . createJid ( number ) ;
1835+ const jid = createJid ( number ) ;
18311836
18321837 try {
18331838 return {
@@ -1843,7 +1848,7 @@ export class BaileysStartupService extends ChannelStartupService {
18431848 }
18441849
18451850 public async fetchProfile ( instanceName : string , number ?: string ) {
1846- const jid = number ? this . createJid ( number ) : this . client ?. user ?. id ;
1851+ const jid = number ? createJid ( number ) : this . client ?. user ?. id ;
18471852
18481853 const onWhatsapp = ( await this . whatsappNumber ( { numbers : [ jid ] } ) ) ?. shift ( ) ;
18491854
@@ -1899,7 +1904,7 @@ export class BaileysStartupService extends ChannelStartupService {
18991904 }
19001905
19011906 public async offerCall ( { number, isVideo, callDuration } : OfferCallDto ) {
1902- const jid = this . createJid ( number ) ;
1907+ const jid = createJid ( number ) ;
19031908
19041909 try {
19051910 const call = await this . client . offerCall ( jid , isVideo ) ;
@@ -2170,7 +2175,7 @@ export class BaileysStartupService extends ChannelStartupService {
21702175 mentions = group . participants . map ( ( participant ) => participant . id ) ;
21712176 } else if ( options ?. mentioned ?. length ) {
21722177 mentions = options . mentioned . map ( ( mention ) => {
2173- const jid = this . createJid ( mention ) ;
2178+ const jid = createJid ( mention ) ;
21742179 if ( isJidGroup ( jid ) ) {
21752180 return null ;
21762181 }
@@ -2292,17 +2297,21 @@ export class BaileysStartupService extends ChannelStartupService {
22922297
22932298 if ( this . localWebhook . enabled ) {
22942299 if ( isMedia && this . localWebhook . webhookBase64 ) {
2295- const buffer = await downloadMediaMessage (
2296- { key : messageRaw . key , message : messageRaw ?. message } ,
2297- 'buffer' ,
2298- { } ,
2299- {
2300- logger : P ( { level : 'error' } ) as any ,
2301- reuploadRequest : this . client . updateMediaMessage ,
2302- } ,
2303- ) ;
2300+ try {
2301+ const buffer = await downloadMediaMessage (
2302+ { key : messageRaw . key , message : messageRaw ?. message } ,
2303+ 'buffer' ,
2304+ { } ,
2305+ {
2306+ logger : P ( { level : 'error' } ) as any ,
2307+ reuploadRequest : this . client . updateMediaMessage ,
2308+ } ,
2309+ ) ;
23042310
2305- messageRaw . message . base64 = buffer ? buffer . toString ( 'base64' ) : undefined ;
2311+ messageRaw . message . base64 = buffer ? buffer . toString ( 'base64' ) : undefined ;
2312+ } catch ( error ) {
2313+ this . logger . error ( [ 'Error converting media to base64' , error ?. message ] ) ;
2314+ }
23062315 }
23072316 }
23082317
@@ -3240,7 +3249,7 @@ export class BaileysStartupService extends ChannelStartupService {
32403249 }
32413250
32423251 if ( ! contact . wuid ) {
3243- contact . wuid = this . createJid ( contact . phoneNumber ) ;
3252+ contact . wuid = createJid ( contact . phoneNumber ) ;
32443253 }
32453254
32463255 result += `item1.TEL;waid=${ contact . wuid } :${ contact . phoneNumber } \n` + 'item1.X-ABLabel:Celular\n' + 'END:VCARD' ;
@@ -3290,7 +3299,7 @@ export class BaileysStartupService extends ChannelStartupService {
32903299 } ;
32913300
32923301 data . numbers . forEach ( ( number ) => {
3293- const jid = this . createJid ( number ) ;
3302+ const jid = createJid ( number ) ;
32943303
32953304 if ( isJidGroup ( jid ) ) {
32963305 jids . groups . push ( { number, jid } ) ;
@@ -3483,7 +3492,7 @@ export class BaileysStartupService extends ChannelStartupService {
34833492 archive : data . archive ,
34843493 lastMessages : [ last_message ] ,
34853494 } ,
3486- this . createJid ( number ) ,
3495+ createJid ( number ) ,
34873496 ) ;
34883497
34893498 return {
@@ -3520,7 +3529,7 @@ export class BaileysStartupService extends ChannelStartupService {
35203529 markRead : false ,
35213530 lastMessages : [ last_message ] ,
35223531 } ,
3523- this . createJid ( number ) ,
3532+ createJid ( number ) ,
35243533 ) ;
35253534
35263535 return {
@@ -3725,7 +3734,7 @@ export class BaileysStartupService extends ChannelStartupService {
37253734
37263735 public async fetchBusinessProfile ( number : string ) : Promise < NumberBusiness > {
37273736 try {
3728- const jid = number ? this . createJid ( number ) : this . instance . wuid ;
3737+ const jid = number ? createJid ( number ) : this . instance . wuid ;
37293738
37303739 const profile = await this . client . getBusinessProfile ( jid ) ;
37313740
@@ -3873,7 +3882,7 @@ export class BaileysStartupService extends ChannelStartupService {
38733882 }
38743883
38753884 public async updateMessage ( data : UpdateMessageDto ) {
3876- const jid = this . createJid ( data . number ) ;
3885+ const jid = createJid ( data . number ) ;
38773886
38783887 const options = await this . formatUpdateMessage ( data ) ;
38793888
@@ -4163,7 +4172,7 @@ export class BaileysStartupService extends ChannelStartupService {
41634172
41644173 const inviteUrl = inviteCode . inviteUrl ;
41654174
4166- const numbers = id . numbers . map ( ( number ) => this . createJid ( number ) ) ;
4175+ const numbers = id . numbers . map ( ( number ) => createJid ( number ) ) ;
41674176 const description = id . description ?? '' ;
41684177
41694178 const msg = `${ description } \n\n${ inviteUrl } ` ;
@@ -4234,7 +4243,7 @@ export class BaileysStartupService extends ChannelStartupService {
42344243
42354244 public async updateGParticipant ( update : GroupUpdateParticipantDto ) {
42364245 try {
4237- const participants = update . participants . map ( ( p ) => this . createJid ( p ) ) ;
4246+ const participants = update . participants . map ( ( p ) => createJid ( p ) ) ;
42384247 const updateParticipants = await this . client . groupParticipantsUpdate (
42394248 update . groupJid ,
42404249 participants ,
0 commit comments