@@ -85,7 +85,6 @@ import {
8585 ArchiveChatDto ,
8686 DeleteMessage ,
8787 OnWhatsAppDto ,
88- NumberBusiness ,
8988 PrivacySettingDto ,
9089 ReadMessageDto ,
9190 WhatsAppNumberDto ,
@@ -1444,79 +1443,6 @@ export class WAStartupService {
14441443 } ;
14451444 }
14461445 }
1447-
1448- public async getStatus ( number : string ) {
1449- const jid = this . createJid ( number ) ;
1450-
1451- this . logger . verbose ( 'Getting profile status with jid:' + jid ) ;
1452- try {
1453- this . logger . verbose ( 'Getting status' ) ;
1454- return {
1455- wuid : jid ,
1456- status : ( await this . client . fetchStatus ( jid ) ) ?. status ,
1457- } ;
1458- } catch ( error ) {
1459- this . logger . verbose ( 'Status not found' ) ;
1460- return {
1461- wuid : jid ,
1462- status : null ,
1463- } ;
1464- }
1465- }
1466-
1467- public async fetchProfile ( instanceName : string , number ?: string ) {
1468- const jid = ( number )
1469- ? this . createJid ( number )
1470- : this . client ?. user ?. id ;
1471- this . logger . verbose ( 'Getting profile with jid: ' + jid ) ;
1472- try {
1473- this . logger . verbose ( 'Getting profile info' ) ;
1474- const business = await this . fetchBusinessProfile ( jid ) ;
1475-
1476- if ( number ) {
1477- const info = ( await this . whatsappNumber ( { numbers : [ jid ] } ) ) ?. shift ( ) ;
1478- const picture = await this . profilePicture ( jid ) ;
1479- const status = await this . getStatus ( jid ) ;
1480-
1481- return {
1482- wuid : jid ,
1483- name : info ?. name ,
1484- numberExists : info ?. exists ,
1485- picture : picture ?. profilePictureUrl ,
1486- status : status ?. status ,
1487- isBusiness : business . isBusiness ,
1488- email : business ?. email ,
1489- description : business ?. description ,
1490- website : business ?. website ?. shift ( ) ,
1491- } ;
1492- } else {
1493- const info = await waMonitor . instanceInfo ( instanceName ) ;
1494-
1495- return {
1496- wuid : jid ,
1497- name : info ?. instance ?. profileName ,
1498- numberExists : true ,
1499- picture : info ?. instance ?. profilePictureUrl ,
1500- status : info ?. instance ?. profileStatus ,
1501- isBusiness : business . isBusiness ,
1502- email : business ?. email ,
1503- description : business ?. description ,
1504- website : business ?. website ?. shift ( ) ,
1505- } ;
1506- }
1507-
1508- } catch ( error ) {
1509- this . logger . verbose ( 'Profile not found' ) ;
1510- return {
1511- wuid : jid ,
1512- name : null ,
1513- picture : null ,
1514- status : null ,
1515- os : null ,
1516- isBusiness : false ,
1517- } ;
1518- }
1519- }
15201446
15211447 private async sendMessageWithTyping < T = proto . IMessage > (
15221448 number : string ,
@@ -2534,31 +2460,29 @@ export class WAStartupService {
25342460 }
25352461 }
25362462
2537- public async fetchBusinessProfile ( number : string ) : Promise < NumberBusiness > {
2463+ public async fetchBusinessProfile ( number : string ) {
25382464 this . logger . verbose ( 'Fetching business profile' ) ;
25392465 try {
2540- const jid = ( number )
2541- ? this . createJid ( number )
2542- : this . instance . wuid ;
2466+ let jid ;
2467+
2468+ if ( ! number ) {
2469+ jid = this . instance . wuid ;
2470+ } else {
2471+ jid = this . createJid ( number ) ;
2472+ }
25432473
25442474 const profile = await this . client . getBusinessProfile ( jid ) ;
25452475 this . logger . verbose ( 'Trying to get business profile' ) ;
25462476
25472477 if ( ! profile ) {
2548- const info = await this . whatsappNumber ( { numbers : [ jid ] } ) ;
2549-
25502478 return {
2551- isBusiness : false ,
2552- message : 'Not is business profile' ,
2553- ...info ?. shift ( )
2479+ exists : false ,
2480+ message : 'Business profile not found' ,
25542481 } ;
25552482 }
25562483
25572484 this . logger . verbose ( 'Business profile fetched' ) ;
2558- return {
2559- isBusiness : true ,
2560- ...profile
2561- } ;
2485+ return profile ;
25622486 } catch ( error ) {
25632487 throw new InternalServerErrorException (
25642488 'Error updating profile name' ,
0 commit comments