@@ -711,7 +711,7 @@ export class WAStartupService {
711711 }
712712 }
713713
714- if ( this . configService . get < Websocket > ( 'WEBSOCKET' ) . ENABLED && this . localWebsocket . enabled ) {
714+ if ( this . configService . get < Websocket > ( 'WEBSOCKET' ) ? .ENABLED && this . localWebsocket . enabled ) {
715715 this . logger . verbose ( 'Sending data to websocket on channel: ' + this . instance . name ) ;
716716 if ( Array . isArray ( websocketLocal ) && websocketLocal . includes ( we ) ) {
717717 this . logger . verbose ( 'Sending data to websocket on event: ' + event ) ;
@@ -1954,9 +1954,10 @@ export class WAStartupService {
19541954 private async sendMessageWithTyping < T = proto . IMessage > ( number : string , message : T , options ?: Options ) {
19551955 this . logger . verbose ( 'Sending message with typing' ) ;
19561956
1957- const numberWA = await this . whatsappNumber ( { numbers : [ number ] } ) ;
1958- const isWA = numberWA [ 0 ] ;
1957+ this . logger . verbose ( `Check if number " ${ number } " is WhatsApp` ) ;
1958+ const isWA = ( await this . whatsappNumber ( { numbers : [ number ] } ) ) ?. shift ( ) ;
19591959
1960+ this . logger . verbose ( `Exists: "${ isWA . exists } " | jid: ${ isWA . jid } ` ) ;
19601961 if ( ! isWA . exists && ! isJidGroup ( isWA . jid ) && ! isWA . jid . includes ( '@broadcast' ) ) {
19611962 throw new BadRequestException ( isWA ) ;
19621963 }
@@ -2000,9 +2001,9 @@ export class WAStartupService {
20002001 let mentions : string [ ] ;
20012002 if ( isJidGroup ( sender ) ) {
20022003 try {
2003- const groupMetadata = await this . client . groupMetadata ( sender ) ;
2004+ const group = await this . findGroup ( { groupJid : sender } , 'inner' ) ;
20042005
2005- if ( ! groupMetadata ) {
2006+ if ( ! group ) {
20062007 throw new NotFoundException ( 'Group not found' ) ;
20072008 }
20082009
@@ -2013,15 +2014,14 @@ export class WAStartupService {
20132014 this . logger . verbose ( 'Mentions everyone' ) ;
20142015
20152016 this . logger . verbose ( 'Getting group metadata' ) ;
2016- mentions = groupMetadata . participants . map ( ( participant ) => participant . id ) ;
2017+ mentions = group . participants . map ( ( participant ) => participant . id ) ;
20172018 this . logger . verbose ( 'Getting group metadata for mentions' ) ;
20182019 } else if ( options . mentions ?. mentioned ?. length ) {
20192020 this . logger . verbose ( 'Mentions manually defined' ) ;
20202021 mentions = options . mentions . mentioned . map ( ( mention ) => {
20212022 const jid = this . createJid ( mention ) ;
20222023 if ( isJidGroup ( jid ) ) {
20232024 return null ;
2024- // throw new BadRequestException('Mentions must be a number');
20252025 }
20262026 return jid ;
20272027 } ) ;
0 commit comments