Skip to content

Commit 004e07a

Browse files
committed
fix org service test expecting member list to include admin
Tool: gitpod/catfood.gitpod.cloud
1 parent ac0e2c5 commit 004e07a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

components/server/src/api/organization-service-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
188188
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "organizationId is required");
189189
}
190190

191-
const members = await this.orgService.listMembers(ctxUserId(), req.organizationId);
191+
const members = await this.orgService.listMembers(ctxUserId(), req.organizationId, true);
192192
//TODO pagination
193193
const response = new ListOrganizationMembersResponse();
194194
response.members = members.map((member) => this.apiConverter.toOrganizationMember(member));
@@ -218,7 +218,7 @@ export class OrganizationServiceAPI implements ServiceImpl<typeof OrganizationSe
218218
this.apiConverter.fromOrgMemberRole(req.role),
219219
);
220220
const member = await this.orgService
221-
.listMembers(ctxUserId(), req.organizationId)
221+
.listMembers(ctxUserId(), req.organizationId, true)
222222
.then((members) => members.find((member) => member.userId === req.userId));
223223
return new UpdateOrganizationMemberResponse({
224224
member: member && this.apiConverter.toOrganizationMember(member),

components/server/src/orgs/organization-service.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,13 @@ export class OrganizationService {
263263
}
264264

265265
/**
266-
* List members of an organization, excluding the built-in installation admin user and all deleted users.
266+
* List members of an organization, excluding all deleted users and optionally the built-in installation admin user.
267267
*/
268-
public async listMembers(userId: string, orgId: string): Promise<OrgMemberInfo[]> {
268+
public async listMembers(
269+
userId: string,
270+
orgId: string,
271+
excludeInstallationAdmin?: boolean,
272+
): Promise<OrgMemberInfo[]> {
269273
await this.auth.checkPermissionOnOrganization(userId, "read_members", orgId);
270274
const members = await this.teamDB.findMembersByTeam(orgId);
271275

@@ -278,7 +282,7 @@ export class OrganizationService {
278282
if (user.markedDeleted) {
279283
return null;
280284
}
281-
if (user.id === BUILTIN_INSTLLATION_ADMIN_USER_ID) {
285+
if (excludeInstallationAdmin && user.id === BUILTIN_INSTLLATION_ADMIN_USER_ID) {
282286
return null;
283287
}
284288

0 commit comments

Comments
 (0)