Page module updates - WIP

This commit is contained in:
Philipinho
2023-09-06 00:53:49 +01:00
parent add9303249
commit 89de5be6ed
5 changed files with 109 additions and 32 deletions
@@ -127,13 +127,7 @@ export class WorkspaceService {
userId: string,
workspaceId: string,
): Promise<void> {
const workspaceUser = await this.workspaceUserRepository.findOne({
where: { userId, workspaceId },
});
if (!workspaceUser) {
throw new BadRequestException('User is not a member of this workspace');
}
await this.validateWorkspaceMember(userId, workspaceId);
await this.workspaceUserRepository.delete({
userId,
@@ -183,4 +177,17 @@ export class WorkspaceService {
return { users };
}
async validateWorkspaceMember(
userId: string,
workspaceId: string,
): Promise<void> {
const workspaceUser = await this.workspaceUserRepository.findOne({
where: { userId, workspaceId },
});
if (!workspaceUser) {
throw new BadRequestException('User is not a member of this workspace');
}
}
}