@@ -2556,6 +2556,12 @@ export class WAStartupService {
25562556 public async fetchProfile ( instanceName : string , number ?: string ) {
25572557 const jid = number ? this . createJid ( number ) : this . client ?. user ?. id ;
25582558
2559+ const onWhatsapp = ( await this . whatsappNumber ( { numbers : [ jid ] } ) ) ?. shift ( ) ;
2560+
2561+ if ( ! onWhatsapp . exists ) {
2562+ throw new BadRequestException ( onWhatsapp ) ;
2563+ }
2564+
25592565 this . logger . verbose ( 'Getting profile with jid: ' + jid ) ;
25602566 try {
25612567 this . logger . verbose ( 'Getting profile info' ) ;
@@ -3966,7 +3972,25 @@ export class WAStartupService {
39663972 public async findGroup ( id : GroupJid , reply : 'inner' | 'out' = 'out' ) {
39673973 this . logger . verbose ( 'Fetching group' ) ;
39683974 try {
3969- return await this . client . groupMetadata ( id . groupJid ) ;
3975+ const group = await this . client . groupMetadata ( id . groupJid ) ;
3976+
3977+ const picture = await this . profilePicture ( group . id ) ;
3978+
3979+ return {
3980+ id : group . id ,
3981+ subject : group . subject ,
3982+ subjectOwner : group . subjectOwner ,
3983+ subjectTime : group . subjectTime ,
3984+ pictureUrl : picture . profilePictureUrl ,
3985+ size : group . participants . length ,
3986+ creation : group . creation ,
3987+ owner : group . owner ,
3988+ desc : group . desc ,
3989+ descId : group . descId ,
3990+ restrict : group . restrict ,
3991+ announce : group . announce ,
3992+ participants : group . participants ,
3993+ } ;
39703994 } catch ( error ) {
39713995 if ( reply === 'inner' ) {
39723996 return ;
@@ -3979,13 +4003,16 @@ export class WAStartupService {
39794003 this . logger . verbose ( 'Fetching all groups' ) ;
39804004 try {
39814005 const fetch = Object . values ( await this . client . groupFetchAllParticipating ( ) ) ;
4006+ let groups = [ ] ;
4007+ for ( const group of fetch ) {
4008+ const picture = await this . profilePicture ( group . id ) ;
39824009
3983- const groups = fetch . map ( ( group ) => {
39844010 const result = {
39854011 id : group . id ,
39864012 subject : group . subject ,
39874013 subjectOwner : group . subjectOwner ,
39884014 subjectTime : group . subjectTime ,
4015+ pictureUrl : picture . profilePictureUrl ,
39894016 size : group . participants . length ,
39904017 creation : group . creation ,
39914018 owner : group . owner ,
@@ -3999,8 +4026,8 @@ export class WAStartupService {
39994026 result [ 'participants' ] = group . participants ;
40004027 }
40014028
4002- return result ;
4003- } ) ;
4029+ groups = [ ... groups , result ] ;
4030+ }
40044031
40054032 return groups ;
40064033 } catch ( error ) {
0 commit comments