Skip to content

Commit

Permalink
rename room-member to room-membership
Browse files Browse the repository at this point in the history
  • Loading branch information
uidp committed Nov 27, 2024
1 parent 6896568 commit df2298e
Show file tree
Hide file tree
Showing 60 changed files with 542 additions and 517 deletions.
15 changes: 15 additions & 0 deletions apps/server/src/migrations/mikro-orm/Migration202411271951208.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Migration } from '@mikro-orm/migrations-mongodb';

export class Migration20241127195120 extends Migration {
async up(): Promise<void> {
const db = this.driver.getConnection().getDb();
await db.renameCollection('room-members', 'room-memberships');
console.info('Collection renamed from room-members to room-memberships');
}

async down(): Promise<void> {
const db = this.driver.getConnection().getDb();
await db.renameCollection('room-memberships', 'room-members');
console.info('Collection renamed from room-memberships to room-members');
}
}
4 changes: 2 additions & 2 deletions apps/server/src/modules/board/board-api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AuthorizationModule } from '@modules/authorization';
import { forwardRef, Module } from '@nestjs/common';
import { CourseRepo } from '@shared/repo/course';
import { LoggerModule } from '@src/core/logger';
import { RoomMemberModule } from '@modules/room-member';
import { RoomMembershipModule } from '@src/modules/room-membership';
import { BoardModule } from './board.module';
import {
BoardController,
Expand All @@ -16,7 +16,7 @@ import { BoardUc, CardUc, ColumnUc, ElementUc, SubmissionItemUc } from './uc';
import { RoomModule } from '../room';

@Module({
imports: [BoardModule, LoggerModule, RoomMemberModule, RoomModule, forwardRef(() => AuthorizationModule)],
imports: [BoardModule, LoggerModule, RoomMembershipModule, RoomModule, forwardRef(() => AuthorizationModule)],
controllers: [BoardController, ColumnController, CardController, ElementController, BoardSubmissionController],
providers: [BoardUc, BoardNodePermissionService, ColumnUc, CardUc, ElementUc, SubmissionItemUc, CourseRepo],
})
Expand Down
11 changes: 9 additions & 2 deletions apps/server/src/modules/board/board-ws-api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UserModule } from '@modules/user';
import { forwardRef, Module } from '@nestjs/common';
import { CourseRepo } from '@shared/repo/course';
import { LoggerModule } from '@src/core/logger';
import { RoomMemberModule } from '../room-member';
import { RoomMembershipModule } from '../room-membership';
import { BoardModule } from './board.module';
import { BoardCollaborationGateway } from './gateway/board-collaboration.gateway';
import { MetricsService } from './metrics/metrics.service';
Expand All @@ -12,7 +12,14 @@ import { BoardUc, CardUc, ColumnUc, ElementUc } from './uc';
import { RoomModule } from '../room';

@Module({
imports: [BoardModule, forwardRef(() => AuthorizationModule), LoggerModule, UserModule, RoomMemberModule, RoomModule],
imports: [
BoardModule,
forwardRef(() => AuthorizationModule),
LoggerModule,
UserModule,
RoomMembershipModule,
RoomModule,
],
providers: [
BoardCollaborationGateway,
BoardNodePermissionService,
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/board/board.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CqrsModule } from '@nestjs/cqrs';
import { CourseRepo } from '@shared/repo/course';
import { LoggerModule } from '@src/core/logger';
import { AuthorizationModule } from '../authorization';
import { RoomMemberModule } from '../room-member';
import { RoomMembershipModule } from '../room-membership';
import { BoardNodeRule } from './authorisation/board-node.rule';
import { BoardNodeFactory } from './domain';
import { BoardNodeRepo } from './repo';
Expand Down Expand Up @@ -46,7 +46,7 @@ import {
CqrsModule,
CollaborativeTextEditorModule,
AuthorizationModule,
RoomMemberModule,
RoomMembershipModule,
],
providers: [
// TODO: move BoardDoAuthorizableService, BoardDoRepo, BoardDoService, BoardNodeRepo in separate module and move mediaboard related services in mediaboard module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TestApiClient, cleanupCollections, groupEntityFactory, roleFactory, use
import { Permission, RoleName } from '@shared/domain/interface';
import { accountFactory } from '@src/modules/account/testing';
import { GroupEntityTypes } from '@src/modules/group/entity';
import { roomMemberEntityFactory } from '@src/modules/room-member/testing';
import { roomMembershipEntityFactory } from '@src/modules/room-membership/testing';
import { roomEntityFactory } from '@src/modules/room/testing';
import { columnBoardEntityFactory } from '../../testing';
import { BoardExternalReferenceType } from '../../domain';
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('board get context in room (api)', () => {

const room = roomEntityFactory.buildWithId();

const roomMember = roomMemberEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });
const roomMember = roomMembershipEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });

await em.persistAndFlush([
accountWithEditRole,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { RoleName } from '@shared/domain/interface/rolename.enum';
import { cleanupCollections, groupEntityFactory, roleFactory, TestApiClient, userFactory } from '@shared/testing';
import { accountFactory } from '@src/modules/account/testing';
import { GroupEntityTypes } from '@src/modules/group/entity';
import { roomMemberEntityFactory } from '@src/modules/room-member/testing';
import { roomMembershipEntityFactory } from '@src/modules/room-membership/testing';
import { roomEntityFactory } from '@src/modules/room/testing';
import { BoardExternalReferenceType, BoardLayout } from '../../domain';
import { BoardNodeEntity } from '../../repo';
Expand Down Expand Up @@ -54,7 +54,7 @@ describe(`create board in room (api)`, () => {

const room = roomEntityFactory.buildWithId();

const roomMember = roomMemberEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });
const roomMember = roomMembershipEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });

await em.persistAndFlush([account, user, role, userGroup, room, roomMember]);
em.clear();
Expand Down Expand Up @@ -170,7 +170,7 @@ describe(`create board in room (api)`, () => {

const room = roomEntityFactory.buildWithId();

const roomMember = roomMemberEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });
const roomMember = roomMembershipEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });

await em.persistAndFlush([account, user, role, userGroup, room, roomMember]);
em.clear();
Expand Down Expand Up @@ -238,7 +238,7 @@ describe(`create board in room (api)`, () => {

const room = roomEntityFactory.buildWithId();

const roomMember = roomMemberEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });
const roomMember = roomMembershipEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });

await em.persistAndFlush([account, user, role, userGroup, room, roomMember]);
em.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { accountFactory } from '@src/modules/account/testing';
import { Permission, RoleName } from '@shared/domain/interface';
import { GroupEntityTypes } from '@src/modules/group/entity';
import { roomEntityFactory } from '@src/modules/room/testing';
import { roomMemberEntityFactory } from '@src/modules/room-member/testing';
import { roomMembershipEntityFactory } from '@src/modules/room-membership/testing';
import { columnBoardEntityFactory, columnEntityFactory } from '../../testing';
import { BoardNodeEntity } from '../../repo';
import { BoardExternalReferenceType } from '../../domain';
Expand Down Expand Up @@ -61,7 +61,7 @@ describe(`board delete in room (api)`, () => {

const room = roomEntityFactory.buildWithId();

const roomMember = roomMemberEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });
const roomMember = roomMembershipEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });

await em.persistAndFlush([
accountWithEditRole,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { cleanupCollections, groupEntityFactory, roleFactory, TestApiClient, use
import { Permission, RoleName } from '@shared/domain/interface';
import { accountFactory } from '@src/modules/account/testing';
import { GroupEntityTypes } from '@src/modules/group/entity';
import { roomMemberEntityFactory } from '@src/modules/room-member/testing';
import { roomMembershipEntityFactory } from '@src/modules/room-membership/testing';
import { roomEntityFactory } from '@src/modules/room/testing';
import { BoardExternalReferenceType, BoardLayout } from '../../domain';
import { BoardResponse } from '../dto';
Expand Down Expand Up @@ -62,7 +62,7 @@ describe(`board lookup in room (api)`, () => {

const room = roomEntityFactory.buildWithId();

const roomMember = roomMemberEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });
const roomMember = roomMembershipEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });

await em.persistAndFlush([
accountWithEditRole,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { TestApiClient, cleanupCollections, groupEntityFactory, roleFactory, use
import { Permission, RoleName } from '@shared/domain/interface';
import { accountFactory } from '@src/modules/account/testing';
import { GroupEntityTypes } from '@src/modules/group/entity';
import { roomMemberEntityFactory } from '@src/modules/room-member/testing';
import { roomMembershipEntityFactory } from '@src/modules/room-membership/testing';
import { roomEntityFactory } from '@src/modules/room/testing';
import { BoardNodeEntity } from '../../repo';
import { columnBoardEntityFactory } from '../../testing';
Expand Down Expand Up @@ -68,7 +68,7 @@ describe(`board update title with room relation (api)`, () => {

const room = roomEntityFactory.buildWithId();

const roomMember = roomMemberEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });
const roomMember = roomMembershipEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });

await em.persistAndFlush([
accountWithEditRole,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TestApiClient, cleanupCollections, groupEntityFactory, roleFactory, use
import { Permission, RoleName } from '@shared/domain/interface';
import { accountFactory } from '@src/modules/account/testing';
import { GroupEntityTypes } from '@src/modules/group/entity';
import { roomMemberEntityFactory } from '@src/modules/room-member/testing';
import { roomMembershipEntityFactory } from '@src/modules/room-membership/testing';
import { roomEntityFactory } from '@src/modules/room/testing';
import { BoardExternalReferenceType } from '../../domain';
import { columnBoardEntityFactory } from '../../testing';
Expand Down Expand Up @@ -67,7 +67,7 @@ describe(`board update visibility with room relation (api)`, () => {

const room = roomEntityFactory.buildWithId();

const roomMember = roomMemberEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });
const roomMember = roomMembershipEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });

await em.persistAndFlush([
accountWithEditRole,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ import { Permission, RoleName } from '@shared/domain/interface';
import { CourseRepo } from '@shared/repo/course';
import { courseFactory, groupFactory, roleFactory, setupEntities, userFactory } from '@shared/testing';
import { GroupTypes } from '@src/modules/group';
import { RoomMemberService } from '@src/modules/room-member';
import { roomMemberFactory } from '@src/modules/room-member/testing';
import { RoomMembershipService } from '@src/modules/room-membership';
import { roomMembershipFactory } from '@src/modules/room-membership/testing';
import { roomFactory } from '@src/modules/room/testing';
import { BoardExternalReferenceType, BoardRoles, UserWithBoardRoles } from '../../domain';
import { columnBoardFactory, columnFactory } from '../../testing';
import { BoardContextService } from './board-context.service';

describe(`${BoardContextService.name}`, () => {
describe(BoardContextService.name, () => {
let module: TestingModule;
let service: BoardContextService;
let courseRepo: DeepMocked<CourseRepo>;
let roomMemberService: DeepMocked<RoomMemberService>;
let roomMembershipService: DeepMocked<RoomMembershipService>;

beforeAll(async () => {
module = await Test.createTestingModule({
providers: [
BoardContextService,
{
provide: RoomMemberService,
useValue: createMock<RoomMemberService>(),
provide: RoomMembershipService,
useValue: createMock<RoomMembershipService>(),
},
{
provide: CourseRepo,
Expand All @@ -34,7 +34,7 @@ describe(`${BoardContextService.name}`, () => {
}).compile();

service = module.get(BoardContextService);
roomMemberService = module.get(RoomMemberService);
roomMembershipService = module.get(RoomMembershipService);
courseRepo = module.get(CourseRepo);

await setupEntities();
Expand Down Expand Up @@ -221,7 +221,7 @@ describe(`${BoardContextService.name}`, () => {
const role = roleFactory.build({ name: RoleName.ROOMEDITOR, permissions: [Permission.ROOM_EDIT] });
const group = groupFactory.build({ type: GroupTypes.ROOM, users: [{ userId: user.id, roleId: role.id }] });
const room = roomFactory.build();
roomMemberFactory.build({ roomId: room.id, userGroupId: group.id });
roomMembershipFactory.build({ roomId: room.id, userGroupId: group.id });
const columnBoard = columnBoardFactory.build({
context: { id: room.id, type: BoardExternalReferenceType.Room },
});
Expand All @@ -232,7 +232,7 @@ describe(`${BoardContextService.name}`, () => {
it('should return their information + editor role', async () => {
const { columnBoard, role, user } = setup();

roomMemberService.getRoomMemberAuthorizable.mockResolvedValue({
roomMembershipService.getRoomMembershipAuthorizable.mockResolvedValue({
id: 'foo',
roomId: columnBoard.context.id,
members: [{ userId: user.id, roles: [role] }],
Expand All @@ -256,7 +256,7 @@ describe(`${BoardContextService.name}`, () => {
const role = roleFactory.build({ name: RoleName.ROOMVIEWER, permissions: [Permission.ROOM_VIEW] });
const group = groupFactory.build({ type: GroupTypes.ROOM, users: [{ userId: user.id, roleId: role.id }] });
const room = roomFactory.build();
roomMemberFactory.build({ roomId: room.id, userGroupId: group.id });
roomMembershipFactory.build({ roomId: room.id, userGroupId: group.id });
const columnBoard = columnBoardFactory.build({
context: { id: room.id, type: BoardExternalReferenceType.Room },
});
Expand All @@ -267,7 +267,7 @@ describe(`${BoardContextService.name}`, () => {
it('should return their information + reader role', async () => {
const { columnBoard, role, user } = setup();

roomMemberService.getRoomMemberAuthorizable.mockResolvedValue({
roomMembershipService.getRoomMembershipAuthorizable.mockResolvedValue({
id: 'foo',
roomId: columnBoard.context.id,
members: [{ userId: user.id, roles: [role] }],
Expand All @@ -291,7 +291,7 @@ describe(`${BoardContextService.name}`, () => {
const role = roleFactory.build();
const group = groupFactory.build({ type: GroupTypes.ROOM, users: [{ userId: user.id, roleId: role.id }] });
const room = roomFactory.build();
roomMemberFactory.build({ roomId: room.id, userGroupId: group.id });
roomMembershipFactory.build({ roomId: room.id, userGroupId: group.id });
const columnBoard = columnBoardFactory.build({
context: { id: room.id, type: BoardExternalReferenceType.Room },
});
Expand All @@ -302,7 +302,7 @@ describe(`${BoardContextService.name}`, () => {
it('should return their information + no role', async () => {
const { columnBoard, role, user } = setup();

roomMemberService.getRoomMemberAuthorizable.mockResolvedValue({
roomMembershipService.getRoomMembershipAuthorizable.mockResolvedValue({
id: 'foo',
roomId: columnBoard.context.id,
members: [{ userId: user.id, roles: [role] }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { Injectable } from '@nestjs/common';
import { Permission } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import { CourseRepo } from '@shared/repo/course';
import { RoomMemberService } from '@src/modules/room-member';
import { UserWithRoomRoles } from '@src/modules/room-member/do/room-member-authorizable.do';
import { RoomMembershipService, UserWithRoomRoles } from '@src/modules/room-membership';
import { AnyBoardNode, BoardExternalReferenceType, BoardRoles, UserWithBoardRoles } from '../../domain';

@Injectable()
export class BoardContextService {
constructor(private readonly courseRepo: CourseRepo, private readonly roomMemberService: RoomMemberService) {}
constructor(private readonly courseRepo: CourseRepo, private readonly roomMembershipService: RoomMembershipService) {}

async getUsersWithBoardRoles(rootNode: AnyBoardNode): Promise<UserWithBoardRoles[]> {
if (!('context' in rootNode)) {
Expand All @@ -31,8 +30,8 @@ export class BoardContextService {
}

private async getFromRoom(roomId: EntityId): Promise<UserWithBoardRoles[]> {
const roomMemberAuthorizable = await this.roomMemberService.getRoomMemberAuthorizable(roomId);
const usersWithRoles: UserWithBoardRoles[] = roomMemberAuthorizable.members.map((member) => {
const roomMembershipAuthorizable = await this.roomMembershipService.getRoomMembershipAuthorizable(roomId);
const usersWithRoles: UserWithBoardRoles[] = roomMembershipAuthorizable.members.map((member) => {
const roles = this.getBoardRolesFromRoomMember(member);
return {
userId: member.userId,
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/modules/board/uc/board.uc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { setupEntities, userFactory } from '@shared/testing';
import { courseFactory } from '@shared/testing/factory';
import { LegacyLogger } from '@src/core/logger';
import { RoomService } from '@src/modules/room';
import { RoomMemberService } from '@src/modules/room-member';
import { RoomMembershipService } from '@src/modules/room-membership';
import { CopyElementType, CopyStatus, CopyStatusEnum } from '../../copy-helper';
import { BoardExternalReferenceType, BoardLayout, BoardNodeFactory, Column, ColumnBoard } from '../domain';
import { BoardNodePermissionService, BoardNodeService, ColumnBoardService } from '../service';
Expand Down Expand Up @@ -58,8 +58,8 @@ describe(BoardUc.name, () => {
useValue: createMock<BoardNodeFactory>(),
},
{
provide: RoomMemberService,
useValue: createMock<RoomMemberService>(),
provide: RoomMembershipService,
useValue: createMock<RoomMembershipService>(),
},
{
provide: LegacyLogger,
Expand Down
8 changes: 4 additions & 4 deletions apps/server/src/modules/board/uc/board.uc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CourseRepo } from '@shared/repo/course';
import { LegacyLogger } from '@src/core/logger';
import { StorageLocation } from '@src/modules/files-storage/interface';
import { RoomService } from '@src/modules/room';
import { RoomMemberService } from '@src/modules/room-member';
import { RoomMembershipService } from '@src/modules/room-membership';
import { CreateBoardBodyParams } from '../controller/dto';
import { BoardExternalReference, BoardExternalReferenceType, BoardNodeFactory, Column, ColumnBoard } from '../domain';
import { BoardNodePermissionService, BoardNodeService, ColumnBoardService } from '../service';
Expand All @@ -19,7 +19,7 @@ export class BoardUc {
@Inject(forwardRef(() => AuthorizationService)) // TODO is this needed?
private readonly authorizationService: AuthorizationService,
private readonly boardPermissionService: BoardNodePermissionService,
private readonly roomMemberService: RoomMemberService,
private readonly roomMembershipService: RoomMembershipService,
private readonly boardNodeService: BoardNodeService,
private readonly columnBoardService: ColumnBoardService,
private readonly logger: LegacyLogger,
Expand Down Expand Up @@ -158,9 +158,9 @@ export class BoardUc {
requiredPermissions: [Permission.COURSE_EDIT],
});
} else if (context.type === BoardExternalReferenceType.Room) {
const roomMemberAuthorizable = await this.roomMemberService.getRoomMemberAuthorizable(context.id);
const roomMembershipAuthorizable = await this.roomMembershipService.getRoomMembershipAuthorizable(context.id);

this.authorizationService.checkPermission(user, roomMemberAuthorizable, {
this.authorizationService.checkPermission(user, roomMembershipAuthorizable, {
action: Action.write,
requiredPermissions: [],
});
Expand Down
9 changes: 0 additions & 9 deletions apps/server/src/modules/room-member/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/server/src/modules/room-member/repo/entity/index.ts

This file was deleted.

Loading

0 comments on commit df2298e

Please sign in to comment.