Skip to content

Commit

Permalink
N21-1783 Remove unused lti message type (#4946)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap authored Apr 19, 2024
1 parent 405f66c commit e0bea57
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 22 deletions.
22 changes: 22 additions & 0 deletions apps/server/src/migrations/mikro-orm/Migration20240419075957.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Migration } from '@mikro-orm/migrations-mongodb';
import { LtiMessageType, ToolConfigType } from '@modules/tool/common/enum';

export class Migration20240419075957 extends Migration {
async up(): Promise<void> {
const result = await this.driver.nativeUpdate(
'external-tools',
{
config_type: ToolConfigType.LTI11,
config_lti_message_type: { $ne: LtiMessageType.BASIC_LTI_LAUNCH_REQUEST },
},
{ config_lti_message_type: LtiMessageType.BASIC_LTI_LAUNCH_REQUEST }
);

console.info(`Changed ${result.affectedRows} lti_message_type(s) to basic-lti-launch-request in external-tools`);
}

// eslint-disable-next-line @typescript-eslint/require-await
async down(): Promise<void> {
console.error(`Migration down not implemented. You might need to restore database from backup!`);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export enum LtiMessageType {
BASIC_LTI_LAUNCH_REQUEST = 'basic-lti-launch-request',
LTI_RESOURCE_LINK_REQUEST = 'LtiResourceLinkRequest',
LTI_DEEP_LINKING_REQUEST = 'LtiDeepLinkingRequest',
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ExternalToolConfigCreateParams } from './external-tool-config.params';

export class Lti11ToolConfigCreateParams extends ExternalToolConfigCreateParams {
@IsEnum(ToolConfigType)
@ApiProperty()
@ApiProperty({ enum: ToolConfigType, enumName: 'ToolConfigType' })
type!: ToolConfigType;

@IsString()
Expand All @@ -21,11 +21,11 @@ export class Lti11ToolConfigCreateParams extends ExternalToolConfigCreateParams
secret!: string;

@IsEnum(LtiMessageType)
@ApiProperty()
@ApiProperty({ enum: LtiMessageType, enumName: 'LtiMessageType' })
lti_message_type!: LtiMessageType;

@IsEnum(LtiPrivacyPermission)
@ApiProperty()
@ApiProperty({ enum: LtiPrivacyPermission, enumName: 'LtiPrivacyPermission' })
privacy_permission!: LtiPrivacyPermission;

@IsLocale()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ExternalToolConfigCreateParams } from './external-tool-config.params';

export class Lti11ToolConfigUpdateParams extends ExternalToolConfigCreateParams {
@IsEnum(ToolConfigType)
@ApiProperty()
@ApiProperty({ enum: ToolConfigType, enumName: 'ToolConfigType' })
type!: ToolConfigType;

@IsString()
Expand All @@ -22,11 +22,11 @@ export class Lti11ToolConfigUpdateParams extends ExternalToolConfigCreateParams
secret?: string;

@IsEnum(LtiMessageType)
@ApiProperty()
@ApiProperty({ enum: LtiMessageType, enumName: 'LtiMessageType' })
lti_message_type!: LtiMessageType;

@IsEnum(LtiPrivacyPermission)
@ApiProperty()
@ApiProperty({ enum: LtiPrivacyPermission, enumName: 'LtiPrivacyPermission' })
privacy_permission!: LtiPrivacyPermission;

@IsLocale()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LtiMessageType, LtiPrivacyPermission, ToolConfigType } from '../../../.
import { ExternalToolConfigResponse } from './external-tool-config.response';

export class Lti11ToolConfigResponse extends ExternalToolConfigResponse {
@ApiProperty()
@ApiProperty({ enum: ToolConfigType, enumName: 'ToolConfigType' })
type: ToolConfigType;

@ApiProperty()
Expand All @@ -12,10 +12,10 @@ export class Lti11ToolConfigResponse extends ExternalToolConfigResponse {
@ApiProperty()
key: string;

@ApiProperty()
@ApiProperty({ enum: LtiMessageType, enumName: 'LtiMessageType' })
lti_message_type: LtiMessageType;

@ApiProperty()
@ApiProperty({ enum: LtiPrivacyPermission, enumName: 'LtiPrivacyPermission' })
privacy_permission: LtiPrivacyPermission;

@ApiProperty()
Expand Down
29 changes: 19 additions & 10 deletions backup/setup/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,47 @@
},
{
"_id": {
"$oid": "65eecc9abaf077b6f9fdb878"
"$oid": "661d0a8f95c6e7265aa4f180"
},
"name": "Migration20240304123509",
"created_at": {
"$date": "2024-03-11T09:19:22.532Z"
"$date": "2024-04-15T11:07:59.291Z"
}
},
{
"_id": {
"$oid": "65fad61d12d7267c5d7a520c"
"$oid": "661d0a8f95c6e7265aa4f181"
},
"name": "Migration20240320122229",
"name": "Migration20240315140224",
"created_at": {
"$date": "2024-03-20T12:27:09.614Z"
"$date": "2024-04-15T11:07:59.301Z"
}
},
{
"_id": {
"$oid": "65faff9f8009e32be883536d"
"$oid": "661d0a8f95c6e7265aa4f182"
},
"name": "Migration20240315140224",
"name": "Migration20240320122229",
"created_at": {
"$date": "2024-03-20T15:24:15.250Z"
"$date": "2024-04-15T11:07:59.306Z"
}
},
{
"_id": {
"$oid": "6602deeb0611e07702de5cb8"
"$oid": "661d0a8f95c6e7265aa4f183"
},
"name": "Migration20240326072506",
"created_at": {
"$date": "2024-03-26T14:42:51.024Z"
"$date": "2024-04-15T11:07:59.312Z"
}
},
{
"_id": {
"$oid": "6622341440e305c6e36dcd81"
},
"name": "Migration20240419075957",
"created_at": {
"$date": "2024-04-19T09:06:28.592Z"
}
}
]
2 changes: 1 addition & 1 deletion scripts/copy-legacy-tool-to-ctl.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const ExternalTool = mongoose.model(
config_secret: String,
config_lti_message_type: {
type: String,
enum: ['basic-lti-launch-request', 'LtiResourceLinkRequest', 'LtiDeepLinkingRequest'],
enum: ['basic-lti-launch-request'],
},
config_privacy_permission: {
type: String,
Expand Down

0 comments on commit e0bea57

Please sign in to comment.