feat: user usage init (#5074)

This commit is contained in:
DarkSky
2023-12-13 09:21:14 +00:00
parent 098787bd0c
commit 77a5552dcd
14 changed files with 818 additions and 11 deletions

View File

@@ -26,6 +26,18 @@ export class PermissionService {
return data?.type as Permission;
}
async getOwnedWorkspaces(userId: string) {
return this.prisma.workspaceUserPermission
.findMany({
where: {
userId,
accepted: true,
type: Permission.Owner,
},
})
.then(data => data.map(({ workspaceId }) => workspaceId));
}
async getWorkspaceOwner(workspaceId: string) {
return this.prisma.workspaceUserPermission.findFirstOrThrow({
where: {