mirror of
https://github.com/docmost/docmost.git
synced 2025-11-22 04:01:12 +10:00
feat: groups
This commit is contained in:
@ -15,6 +15,7 @@ import { Page } from '../../page/entities/page.entity';
|
||||
import { WorkspaceInvitation } from './workspace-invitation.entity';
|
||||
import { Comment } from '../../comment/entities/comment.entity';
|
||||
import { Space } from '../../space/entities/space.entity';
|
||||
import { Group } from '../../group/entities/group.entity';
|
||||
|
||||
@Entity('workspaces')
|
||||
export class Workspace {
|
||||
@ -82,4 +83,7 @@ export class Workspace {
|
||||
|
||||
@OneToMany(() => Space, (space) => space.workspace)
|
||||
spaces: [];
|
||||
|
||||
@OneToMany(() => Group, (group) => group.workspace)
|
||||
groups: [];
|
||||
}
|
||||
|
||||
@ -34,10 +34,6 @@ export class WorkspaceUserService {
|
||||
|
||||
await transactionWrapper(
|
||||
async (manager) => {
|
||||
const existingWorkspaceUser = await manager.findOne(WorkspaceUser, {
|
||||
where: { userId: userId, workspaceId: workspaceId },
|
||||
});
|
||||
|
||||
const userExists = await manager.exists(User, {
|
||||
where: { id: userId },
|
||||
});
|
||||
@ -45,6 +41,11 @@ export class WorkspaceUserService {
|
||||
throw new NotFoundException('User not found');
|
||||
}
|
||||
|
||||
const existingWorkspaceUser = await manager.findOneBy(WorkspaceUser, {
|
||||
userId: userId,
|
||||
workspaceId: workspaceId,
|
||||
});
|
||||
|
||||
if (existingWorkspaceUser) {
|
||||
throw new BadRequestException(
|
||||
'User is already a member of this workspace',
|
||||
|
||||
@ -82,6 +82,7 @@ export class WorkspaceService {
|
||||
userId,
|
||||
createdSpace.id,
|
||||
WorkspaceUserRole.OWNER,
|
||||
createdWorkspace.id,
|
||||
manager,
|
||||
);
|
||||
|
||||
@ -110,6 +111,7 @@ export class WorkspaceService {
|
||||
userId,
|
||||
firstWorkspace[0].defaultSpaceId,
|
||||
WorkspaceUserRole.MEMBER,
|
||||
firstWorkspace[0].id,
|
||||
manager,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user