File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -2800,8 +2800,19 @@ export class BaileysStartupService extends WAStartupService {
28002800 public async blockUser ( data : BlockUserDto ) {
28012801 this . logger . verbose ( 'Blocking user: ' + data . number ) ;
28022802 try {
2803- const jid = this . createJid ( data . number ) ;
2804- await this . client . updateBlockStatus ( jid , data . status ) ;
2803+ const { number } = data ;
2804+
2805+ this . logger . verbose ( `Check if number "${ number } " is WhatsApp` ) ;
2806+ const isWA = ( await this . whatsappNumber ( { numbers : [ number ] } ) ) ?. shift ( ) ;
2807+
2808+ this . logger . verbose ( `Exists: "${ isWA . exists } " | jid: ${ isWA . jid } ` ) ;
2809+ if ( ! isWA . exists && ! isJidGroup ( isWA . jid ) && ! isWA . jid . includes ( '@broadcast' ) ) {
2810+ throw new BadRequestException ( isWA ) ;
2811+ }
2812+
2813+ const sender = isWA . jid ;
2814+
2815+ await this . client . updateBlockStatus ( sender , data . status ) ;
28052816
28062817 return { block : 'success' } ;
28072818 } catch ( error ) {
You can’t perform that action at this time.
0 commit comments