Skip to content

Commit

Permalink
Merge pull request #381 from internxt/fix/get-teams-permissions-and-f…
Browse files Browse the repository at this point in the history
…ilter-default-team

[_] fix: fixed  get workspace teams endpoint permissions and response
  • Loading branch information
apsantiso authored Aug 5, 2024
2 parents f125796 + 3fc9946 commit fb062dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/modules/workspaces/workspaces.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,13 @@ export class WorkspacesController {
@ApiOkResponse({
description: 'Teams in the workspace along with its members quantity',
})
@UseGuards(WorkspaceGuard)
@WorkspaceRequiredAccess(AccessContext.WORKSPACE, WorkspaceRole.MEMBER)
async getWorkspaceTeams(
@Param('workspaceId', ValidateUUIDPipe)
workspaceId: WorkspaceAttributes['id'],
@UserDecorator() user: User,
) {
if (!workspaceId || !isUUID(workspaceId)) {
throw new BadRequestException('Invalid workspace ID');
}

return this.workspaceUseCases.getWorkspaceTeams(user, workspaceId);
}

Expand Down
7 changes: 5 additions & 2 deletions src/modules/workspaces/workspaces.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,6 @@ export class WorkspacesUsecases {

async getWorkspaceTeams(user: User, workspaceId: WorkspaceAttributes['id']) {
const workspace = await this.workspaceRepository.findOne({
ownerId: user.uuid,
id: workspaceId,
});

Expand All @@ -1630,7 +1629,11 @@ export class WorkspacesUsecases {
workspace.id,
);

return teamsWithMemberCount;
const teamsWithouDefaultTeam = teamsWithMemberCount.filter(
(teamAndMembers) => workspace.defaultTeamId !== teamAndMembers.team.id,
);

return teamsWithouDefaultTeam;
}

async getWorkspaceMembers(
Expand Down

0 comments on commit fb062dd

Please sign in to comment.