@@ -6,6 +6,7 @@ import { GroupUser } from './entities/group-user.entity';
66import { CreateGroupDto } from './dto/create-group.dto' ;
77import { UpdateGroupDto } from './dto/update-group.dto' ;
88import { User } from 'src/user/user.entity' ;
9+ import { NamespacesService } from 'src/namespaces/namespaces.service' ;
910
1011@Injectable ( )
1112export class GroupsService {
@@ -15,6 +16,7 @@ export class GroupsService {
1516 @InjectRepository ( GroupUser )
1617 private readonly groupUserRepository : Repository < GroupUser > ,
1718 private readonly dataSource : DataSource ,
19+ private readonly namespaceService : NamespacesService ,
1820 ) { }
1921
2022 async listGroups ( namespaceId : string ) : Promise < Group [ ] > {
@@ -91,14 +93,25 @@ export class GroupsService {
9193 }
9294
9395 async listGroupUsers ( namespaceId : string , groupId : string ) : Promise < User [ ] > {
94- const users = await this . groupUserRepository . find ( {
96+ const groupUsers = await this . groupUserRepository . find ( {
9597 where : {
9698 namespace : { id : namespaceId } ,
9799 group : { id : groupId } ,
98100 } ,
99101 relations : [ 'user' ] ,
100102 } ) ;
101- return users . map ( ( user ) => user . user ) ;
103+ return await Promise . all (
104+ groupUsers . map ( ( groupUser ) =>
105+ this . namespaceService
106+ . getMemberByUserId ( namespaceId , groupUser . user . id )
107+ . then ( ( member ) =>
108+ Promise . resolve ( {
109+ role : member ? member . role : 'member' ,
110+ ...groupUser . user ,
111+ } ) ,
112+ ) ,
113+ ) ,
114+ ) ;
102115 }
103116
104117 async addGroupUser (
0 commit comments