Skip to content

Commit

Permalink
simplified environment authority fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Dec 31, 2024
1 parent 62c5751 commit 2a9d188
Showing 1 changed file with 10 additions and 27 deletions.
37 changes: 10 additions & 27 deletions apps/api/src/common/collective-authorities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,28 +118,17 @@ export const getCollectiveEnvironmentAuthorities = async (
workspaceMember: {
userId,
workspaceId: environment.project.workspaceId
}
},
select: {
},
role: {
select: {
authorities: true
}
}
}
})

if (projectRoleAssociations.length === 0) {
return authorities
}

const environmentRoleAssociations =
await prisma.projectWorkspaceRoleAssociation.findMany({
where: {
projectId: environment.project.id,
environments: {
some: {
id: environment.id
projects: {
some: {
projectId: environment.project.id,
environments: {
some: {
id: environment.id
}
}
}
}
}
},
Expand All @@ -158,11 +147,5 @@ export const getCollectiveEnvironmentAuthorities = async (
})
})

environmentRoleAssociations.forEach((roleAssociation) => {
roleAssociation.role.authorities.forEach((authority) => {
authorities.add(authority)
})
})

return authorities
}

0 comments on commit 2a9d188

Please sign in to comment.