Skip to content

Commit

Permalink
Merge branch 'main' into EW-1060
Browse files Browse the repository at this point in the history
  • Loading branch information
Fshmit authored Dec 16, 2024
2 parents 2d480a2 + 0b4dacc commit bfdf09e
Show file tree
Hide file tree
Showing 118 changed files with 4,473 additions and 281 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface SchulconnexClientConfig {
SCHULCONNEX_CLIENT__PERSON_INFO_TIMEOUT_IN_MS: number;
SCHULCONNEX_CLIENT__PERSONEN_INFO_TIMEOUT_IN_MS: number;
SCHULCONNEX_CLIENT__POLICIES_INFO_TIMEOUT_IN_MS: number;
SCHULCONNEX_CLIENT__API_URL?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SchulconnexRestClientOptions } from './schulconnex-rest-client-options'

@Module({})
export class SchulconnexClientModule {
static registerAsync(): DynamicModule {
public static registerAsync(): DynamicModule {
return {
imports: [HttpModule, LoggerModule],
module: SchulconnexClientModule,
Expand All @@ -27,6 +27,7 @@ export class SchulconnexClientModule {
tokenEndpoint: configService.get<string>('SCHULCONNEX_CLIENT__TOKEN_ENDPOINT'),
clientId: configService.get<string>('SCHULCONNEX_CLIENT__CLIENT_ID'),
clientSecret: configService.get<string>('SCHULCONNEX_CLIENT__CLIENT_SECRET'),
personInfoTimeoutInMs: configService.get<number>('SCHULCONNEX_CLIENT__PERSON_INFO_TIMEOUT_IN_MS'),
personenInfoTimeoutInMs: configService.get<number>('SCHULCONNEX_CLIENT__PERSONEN_INFO_TIMEOUT_IN_MS'),
policiesInfoTimeoutInMs: configService.get<number>('SCHULCONNEX_CLIENT__POLICIES_INFO_TIMEOUT_IN_MS'),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export interface SchulconnexRestClientOptions {

clientSecret?: string;

personInfoTimeoutInMs?: number;

personenInfoTimeoutInMs?: number;

policiesInfoTimeoutInMs?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ describe(SchulconnexRestClient.name, () => {
clientId: 'clientId',
clientSecret: 'clientSecret',
tokenEndpoint: 'https://schulconnex.url/token',
personenInfoTimeoutInMs: 30000,
policiesInfoTimeoutInMs: 30000,
personInfoTimeoutInMs: 30001,
personenInfoTimeoutInMs: 30002,
policiesInfoTimeoutInMs: 30003,
};

beforeAll(() => {
Expand Down Expand Up @@ -100,6 +101,7 @@ describe(SchulconnexRestClient.name, () => {
Authorization: `Bearer ${accessToken}`,
'Accept-Encoding': 'gzip',
},
timeout: options.personInfoTimeoutInMs,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ export class SchulconnexRestClient implements SchulconnexApiInterface {
this.SCHULCONNEX_API_BASE_URL = options.apiUrl || '';
}

public async getPersonInfo(accessToken: string, options?: { overrideUrl: string }): Promise<SchulconnexResponse> {
public getPersonInfo(accessToken: string, options?: { overrideUrl: string }): Promise<SchulconnexResponse> {
const url: URL = new URL(options?.overrideUrl ?? `${this.SCHULCONNEX_API_BASE_URL}/person-info`);

const response: Promise<SchulconnexResponse> = this.getRequest<SchulconnexResponse>(url, accessToken);
const response: Promise<SchulconnexResponse> = this.getRequest<SchulconnexResponse>(
url,
accessToken,
this.options.personInfoTimeoutInMs
);

return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class Migration20241113100535 extends Migration {
);

if (teacherRoleUpdate.modifiedCount > 0) {
console.info('Rollback: Permission ROOM_CREATE added to role teacher.');
console.info('Rollback: Permission ROOM_CREATE removed from role teacher.');
}

const roomEditorRoleUpdate = await this.getCollection('roles').updateOne(
Expand All @@ -61,7 +61,7 @@ export class Migration20241113100535 extends Migration {
);

if (roomEditorRoleUpdate.modifiedCount > 0) {
console.info('Rollback: Permission ROOM_DELETE added to role roomeditor.');
console.info('Rollback: Permission ROOM_DELETE removed from role roomeditor.');
}
}
}
40 changes: 40 additions & 0 deletions apps/server/src/migrations/mikro-orm/Migration20241209165812.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Migration } from '@mikro-orm/migrations-mongodb';

export class Migration20241209165812 extends Migration {
async up(): Promise<void> {
// Add ROOM_OWNER role
await this.getCollection('roles').insertOne({
name: 'roomowner',
permissions: [
'ROOM_VIEW',
'ROOM_EDIT',
'ROOM_DELETE',
'ROOM_MEMBERS_ADD',
'ROOM_MEMBERS_REMOVE',
'ROOM_CHANGE_OWNER',
],
});
console.info(
'Added ROOM_OWNER role with ROOM_VIEW, -_EDIT, _DELETE, -_MEMBERS_ADD, -_MEMBERS_REMOVE AND -_CHANGE_OWNER permission'
);

// Add ROOM_ADMIN role
await this.getCollection('roles').insertOne({
name: 'roomadmin',
permissions: ['ROOM_VIEW', 'ROOM_EDIT', 'ROOM_MEMBERS_ADD', 'ROOM_MEMBERS_REMOVE'],
});
console.info(
'Added ROOM_ADMIN role with ROOM_VIEW, ROOM_EDIT, ROOM_MEMBERS_ADD AND ROOM_MEMBERS_REMOVE permissions'
);
}

async down(): Promise<void> {
// Remove ROOM_OWNER role
await this.getCollection('roles').deleteOne({ name: 'roomowner' });
console.info('Rollback: Removed ROOM_OWNER role');

// Remove ROOM_ADMIN role
await this.getCollection('roles').deleteOne({ name: 'roomadmin' });
console.info('Rollback: Removed ROOM_ADMIN role');
}
}
35 changes: 35 additions & 0 deletions apps/server/src/migrations/mikro-orm/Migration20241210152600.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Migration } from '@mikro-orm/migrations-mongodb';

export class Migration20241210152600 extends Migration {
async up(): Promise<void> {
const roomEditorRoleUpdate = await this.getCollection('roles').updateOne(
{ name: 'roomeditor' },
{
$set: {
permissions: ['ROOM_VIEW', 'ROOM_EDIT'],
},
}
);

if (roomEditorRoleUpdate.modifiedCount > 0) {
console.info('Permission ROOM_DELETE removed from role roomeditor.');
}
}

async down(): Promise<void> {
const roomEditorRoleUpdate = await this.getCollection('roles').updateOne(
{ name: 'roomeditor' },
{
$set: {
permissions: ['ROOM_VIEW', 'ROOM_EDIT', 'ROOM_DELETE'],
},
}
);

if (roomEditorRoleUpdate.modifiedCount > 0) {
console.info(
'Rollback: Permissions ROOM_DELETE added to and ROOM_MEMBERS_ADD and ROOM_MEMBERS_REMOVE removed from role roomeditor.'
);
}
}
}
11 changes: 11 additions & 0 deletions apps/server/src/migrations/mikro-orm/Migration20241213145222.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Migration } from '@mikro-orm/migrations-mongodb';

export class Migration20241213145222 extends Migration {
public async up(): Promise<void> {
await this.getCollection('files').createIndex({ 'securityCheck.requestToken': 1 });
}

public async down(): Promise<void> {
// no need
}
}
5 changes: 4 additions & 1 deletion apps/server/src/modules/board/controller/card.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
RenameBodyParams,
RichTextElementResponse,
SubmissionContainerElementResponse,
VideoConferenceElementResponse,
} from './dto';
import { SetHeightBodyParams } from './dto/board/set-height.body.params';
import { CardResponseMapper, ContentElementResponseFactory } from './mapper';
Expand Down Expand Up @@ -124,7 +125,8 @@ export class CardController {
RichTextElementResponse,
SubmissionContainerElementResponse,
DrawingElementResponse,
DeletedElementResponse
DeletedElementResponse,
VideoConferenceElementResponse
)
@ApiResponse({
status: 201,
Expand All @@ -137,6 +139,7 @@ export class CardController {
{ $ref: getSchemaPath(SubmissionContainerElementResponse) },
{ $ref: getSchemaPath(DrawingElementResponse) },
{ $ref: getSchemaPath(DeletedElementResponse) },
{ $ref: getSchemaPath(VideoConferenceElementResponse) },
],
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
LinkElementResponse,
RichTextElementResponse,
SubmissionContainerElementResponse,
VideoConferenceElementResponse,
} from '../element';
import { TimestampsResponse } from '../timestamps.response';
import { VisibilitySettingsResponse } from './visibility-settings.response';
Expand All @@ -22,7 +23,8 @@ import { VisibilitySettingsResponse } from './visibility-settings.response';
DrawingElementResponse,
SubmissionContainerElementResponse,
CollaborativeTextEditorElementResponse,
DeletedElementResponse
DeletedElementResponse,
VideoConferenceElementResponse
)
export class CardResponse {
constructor({ id, title, height, elements, visibilitySettings, timestamps }: CardResponse) {
Expand Down Expand Up @@ -58,6 +60,7 @@ export class CardResponse {
{ $ref: getSchemaPath(DrawingElementResponse) },
{ $ref: getSchemaPath(CollaborativeTextEditorElementResponse) },
{ $ref: getSchemaPath(DeletedElementResponse) },
{ $ref: getSchemaPath(VideoConferenceElementResponse) },
],
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FileElementResponse } from './file-element.response';
import { LinkElementResponse } from './link-element.response';
import { RichTextElementResponse } from './rich-text-element.response';
import { SubmissionContainerElementResponse } from './submission-container-element.response';
import { VideoConferenceElementResponse } from './video-conference-element.response';

export type AnyContentElementResponse =
| FileElementResponse
Expand All @@ -15,7 +16,8 @@ export type AnyContentElementResponse =
| ExternalToolElementResponse
| DrawingElementResponse
| CollaborativeTextEditorElementResponse
| DeletedElementResponse;
| DeletedElementResponse
| VideoConferenceElementResponse;

export const isFileElementResponse = (element: AnyContentElementResponse): element is FileElementResponse =>
element instanceof FileElementResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export * from './link-element.response';
export * from './rich-text-element.response';
export * from './submission-container-element.response';
export * from './update-element-content.body.params';
export * from './video-conference-element.response';
export * from './deleted-element.response';
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,29 @@ export class ExternalToolElementContentBody extends ElementContentBody {
content!: ExternalToolContentBody;
}

export class VideoConferenceContentBody {
@IsString()
@ApiProperty()
title!: string;
}

export class VideoConferenceElementContentBody extends ElementContentBody {
@ApiProperty({ type: ContentElementType.VIDEO_CONFERENCE })
type!: ContentElementType.VIDEO_CONFERENCE;

@ValidateNested()
@ApiProperty()
content!: VideoConferenceContentBody;
}

export type AnyElementContentBody =
| FileContentBody
| DrawingContentBody
| LinkContentBody
| RichTextContentBody
| SubmissionContainerContentBody
| ExternalToolContentBody;
| ExternalToolContentBody
| VideoConferenceContentBody;

export class UpdateElementContentBodyParams {
@ValidateNested()
Expand All @@ -156,6 +172,7 @@ export class UpdateElementContentBodyParams {
{ value: SubmissionContainerElementContentBody, name: ContentElementType.SUBMISSION_CONTAINER },
{ value: ExternalToolElementContentBody, name: ContentElementType.EXTERNAL_TOOL },
{ value: DrawingElementContentBody, name: ContentElementType.DRAWING },
{ value: VideoConferenceElementContentBody, name: ContentElementType.VIDEO_CONFERENCE },
],
},
keepDiscriminatorProperty: true,
Expand All @@ -168,6 +185,7 @@ export class UpdateElementContentBodyParams {
{ $ref: getSchemaPath(SubmissionContainerElementContentBody) },
{ $ref: getSchemaPath(ExternalToolElementContentBody) },
{ $ref: getSchemaPath(DrawingElementContentBody) },
{ $ref: getSchemaPath(VideoConferenceElementContentBody) },
],
})
data!:
Expand All @@ -176,5 +194,6 @@ export class UpdateElementContentBodyParams {
| RichTextElementContentBody
| SubmissionContainerElementContentBody
| ExternalToolElementContentBody
| DrawingElementContentBody;
| DrawingElementContentBody
| VideoConferenceElementContentBody;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ApiProperty } from '@nestjs/swagger';
import { ContentElementType } from '../../../domain';
import { TimestampsResponse } from '../timestamps.response';

export class VideoConferenceElementContent {
constructor({ title }: VideoConferenceElementContent) {
this.title = title;
}

@ApiProperty()
title: string;
}

export class VideoConferenceElementResponse {
constructor({ id, content, timestamps, type }: VideoConferenceElementResponse) {
this.id = id;
this.timestamps = timestamps;
this.type = type;
this.content = content;
}

@ApiProperty({ pattern: '[a-f0-9]{24}' })
id: string;

@ApiProperty({ enum: ContentElementType, enumName: 'ContentElementType' })
type: ContentElementType.VIDEO_CONFERENCE;

@ApiProperty()
timestamps: TimestampsResponse;

@ApiProperty()
content: VideoConferenceElementContent;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
SubmissionContainerElementResponse,
SubmissionItemResponse,
UpdateElementContentBodyParams,
VideoConferenceElementContentBody,
VideoConferenceElementResponse,
} from './dto';
import { ContentElementResponseFactory, SubmissionItemResponseMapper } from './mapper';

Expand Down Expand Up @@ -71,7 +73,8 @@ export class ElementController {
SubmissionContainerElementContentBody,
ExternalToolElementContentBody,
LinkElementContentBody,
DrawingElementContentBody
DrawingElementContentBody,
VideoConferenceElementContentBody
)
@ApiResponse({
status: 200,
Expand All @@ -83,6 +86,7 @@ export class ElementController {
{ $ref: getSchemaPath(RichTextElementResponse) },
{ $ref: getSchemaPath(SubmissionContainerElementResponse) },
{ $ref: getSchemaPath(DrawingElementResponse) },
{ $ref: getSchemaPath(VideoConferenceElementResponse) },
],
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class CollaborativeTextEditorElementResponseMapper implements BaseRespons
return result;
}

canMap(element: CollaborativeTextEditorElement): boolean {
canMap(element: unknown): boolean {
return element instanceof CollaborativeTextEditorElement;
}
}
Loading

0 comments on commit bfdf09e

Please sign in to comment.