1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 20:52:42 +01:00

🐛 fix invites: ajv doesn't treat null as undefined

This commit is contained in:
Flam3rboy 2021-09-13 00:00:11 +02:00
parent 33533fc183
commit e32bb24fa8
4 changed files with 266 additions and 333 deletions

View File

@ -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": {

View File

@ -15,7 +15,7 @@ const settings: TJS.PartialArgs = {
defaultProps: false
};
const compilerOptions: TJS.CompilerOptions = {
strictNullChecks: false
strictNullChecks: true
};
const ExcludedSchemas = ["DefaultSchema", "Schema", "EntitySchema"];

View File

@ -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;

View File

@ -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)) {