From e32bb24fa84e5942168433b16f3b0d86aa455a99 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Mon, 13 Sep 2021 00:00:11 +0200 Subject: :bug: fix invites: ajv doesn't treat null as undefined --- api/assets/schemas.json | 592 +++++++++++-------------- api/scripts/generate_body_schema.ts | 2 +- api/src/routes/channels/#channel_id/invites.ts | 4 +- api/src/util/route.ts | 1 - 4 files changed, 266 insertions(+), 333 deletions(-) diff --git a/api/assets/schemas.json b/api/assets/schemas.json index 59ab4c04..ac7df859 100644 --- a/api/assets/schemas.json +++ b/api/assets/schemas.json @@ -177,7 +177,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -274,17 +282,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -499,7 +496,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -596,17 +601,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -718,10 +712,16 @@ "type": "string" }, "target_type": { - "type": "string" + "type": [ + "null", + "string" + ] }, "validate": { - "type": "string" + "type": [ + "null", + "string" + ] }, "max_age": { "type": "integer" @@ -774,7 +774,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -871,17 +879,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -1028,7 +1025,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -1125,17 +1130,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -1285,7 +1279,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -1382,17 +1384,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -1551,7 +1542,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -1648,17 +1647,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -1810,7 +1798,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -1907,17 +1903,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -2064,7 +2049,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -2161,17 +2154,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -2330,7 +2312,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -2427,17 +2417,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -2606,7 +2585,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -2703,17 +2690,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -2915,7 +2891,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -3012,17 +2996,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -3169,7 +3142,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -3266,17 +3247,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -3423,7 +3393,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -3520,17 +3498,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -3689,7 +3656,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -3786,17 +3761,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -3950,7 +3914,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -4047,17 +4019,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -4207,7 +4168,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -4304,17 +4273,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -4464,7 +4422,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -4561,17 +4527,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -4717,7 +4672,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -4814,17 +4777,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -4990,7 +4942,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -5087,17 +5047,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -5270,7 +5219,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -5367,17 +5324,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -5528,7 +5474,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -5625,17 +5579,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -5785,7 +5728,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -5882,17 +5833,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -6045,7 +5985,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -6142,17 +6090,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -6266,17 +6203,26 @@ "type": "string" }, "avatar": { - "type": "string" + "type": [ + "null", + "string" + ] }, "bio": { "maxLength": 1024, "type": "string" }, "accent_color": { - "type": "integer" + "type": [ + "null", + "integer" + ] }, "banner": { - "type": "string" + "type": [ + "null", + "string" + ] }, "password": { "type": "string" @@ -6320,7 +6266,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -6417,17 +6371,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -6574,7 +6517,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -6671,17 +6622,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -6832,7 +6772,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -6929,17 +6877,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { @@ -7273,7 +7210,15 @@ "type": "string" }, "type": { - "$ref": "#/definitions/EmbedType" + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" }, "description": { "type": "string" @@ -7370,17 +7315,6 @@ }, "additionalProperties": false }, - "EmbedType": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, "EmbedImage": { "type": "object", "properties": { diff --git a/api/scripts/generate_body_schema.ts b/api/scripts/generate_body_schema.ts index c406cab8..316e5a69 100644 --- a/api/scripts/generate_body_schema.ts +++ b/api/scripts/generate_body_schema.ts @@ -15,7 +15,7 @@ const settings: TJS.PartialArgs = { defaultProps: false }; const compilerOptions: TJS.CompilerOptions = { - strictNullChecks: false + strictNullChecks: true }; const ExcludedSchemas = ["DefaultSchema", "Schema", "EntitySchema"]; diff --git a/api/src/routes/channels/#channel_id/invites.ts b/api/src/routes/channels/#channel_id/invites.ts index 39263185..2edb4fc2 100644 --- a/api/src/routes/channels/#channel_id/invites.ts +++ b/api/src/routes/channels/#channel_id/invites.ts @@ -9,8 +9,8 @@ const router: Router = Router(); export interface InviteCreateSchema { target_user_id?: string; - target_type?: string; - validate?: string; //? wtf is this + target_type?: string | null; + validate?: string | null; // ? what is this max_age?: number; max_uses?: number; temporary?: boolean; diff --git a/api/src/util/route.ts b/api/src/util/route.ts index f618a630..6cd8f622 100644 --- a/api/src/util/route.ts +++ b/api/src/util/route.ts @@ -55,7 +55,6 @@ export function route(opts: RouteOptions) { if (opts.permission) { const required = new Permissions(opts.permission); const permission = await getPermission(req.user_id, req.params.guild_id, req.params.channel_id); - console.log(required.bitfield, permission.bitfield, permission.bitfield & required.bitfield); // bitfield comparison: check if user lacks certain permission if (!permission.has(required)) { -- cgit 1.4.1