diff --git a/api/assets/schemas.json b/api/assets/schemas.json
index 023f2092..03a2db07 100644
--- a/api/assets/schemas.json
+++ b/api/assets/schemas.json
@@ -21,7 +21,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"login",
"password"
@@ -64,7 +63,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"consent",
"username"
@@ -133,7 +131,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -158,7 +155,6 @@
"type": "integer"
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -210,7 +206,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -233,8 +228,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -251,8 +245,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -269,15 +262,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -294,8 +285,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -359,7 +349,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -383,8 +372,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -417,7 +405,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -440,7 +427,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -498,8 +484,7 @@
"replied_user": {
"type": "boolean"
}
- },
- "additionalProperties": false
+ }
},
"message_reference": {
"type": "object",
@@ -517,7 +502,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"channel_id",
"message_id"
@@ -532,7 +516,6 @@
"items": {}
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -584,7 +567,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -607,8 +589,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -625,8 +606,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -643,15 +623,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -668,8 +646,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -733,7 +710,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -757,8 +733,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -791,7 +766,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -814,7 +788,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -855,7 +828,6 @@
"type": "integer"
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -907,7 +879,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -930,8 +901,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -948,8 +918,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -966,15 +935,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -991,8 +958,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -1056,7 +1022,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -1080,8 +1045,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -1114,7 +1078,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -1137,7 +1100,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -1157,7 +1119,6 @@
"type": "integer"
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -1209,7 +1170,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -1232,8 +1192,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -1250,8 +1209,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -1268,15 +1226,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -1293,8 +1249,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -1358,7 +1313,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -1382,8 +1336,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -1416,7 +1369,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -1439,7 +1391,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -1459,7 +1410,6 @@
}
}
},
- "additionalProperties": false,
"required": [
"messages"
],
@@ -1514,7 +1464,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -1537,8 +1486,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -1555,8 +1503,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -1573,15 +1520,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -1598,8 +1543,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -1663,7 +1607,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -1687,8 +1630,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -1721,7 +1663,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -1744,7 +1685,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -1770,7 +1710,6 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -1828,7 +1767,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -1851,8 +1789,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -1869,8 +1806,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -1887,15 +1823,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -1912,8 +1846,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -1977,7 +1910,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -2001,8 +1933,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -2035,7 +1966,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -2058,7 +1988,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -2079,7 +2008,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"avatar",
"name"
@@ -2135,7 +2063,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -2158,8 +2085,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -2176,8 +2102,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -2194,15 +2119,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -2219,8 +2142,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -2284,7 +2206,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -2308,8 +2229,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -2342,7 +2262,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -2365,7 +2284,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -2385,7 +2303,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -2437,7 +2354,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -2460,8 +2376,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -2478,8 +2393,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -2496,15 +2410,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -2521,8 +2433,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -2586,7 +2497,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -2610,8 +2520,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -2644,7 +2553,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -2667,7 +2575,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -2695,7 +2602,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"id"
]
@@ -2751,7 +2657,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -2774,8 +2679,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -2792,8 +2696,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -2810,15 +2713,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -2835,8 +2736,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -2900,7 +2800,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -2924,8 +2823,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -2958,7 +2856,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -2981,7 +2878,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -3023,7 +2919,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"name"
],
@@ -3078,7 +2973,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -3101,8 +2995,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -3119,8 +3012,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -3137,15 +3029,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -3162,8 +3052,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -3227,7 +3116,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -3251,8 +3139,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -3285,7 +3172,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -3308,7 +3194,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -3389,7 +3274,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"name"
],
@@ -3444,7 +3328,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -3467,8 +3350,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -3485,8 +3367,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -3503,15 +3384,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -3528,8 +3407,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -3593,7 +3471,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -3617,8 +3494,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -3651,7 +3527,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -3674,7 +3549,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -3694,7 +3568,6 @@
}
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -3746,7 +3619,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -3769,8 +3641,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -3787,8 +3658,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -3805,15 +3675,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -3830,8 +3698,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -3895,7 +3762,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -3919,8 +3785,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -3953,7 +3818,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -3976,7 +3840,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -3993,7 +3856,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"nick"
],
@@ -4048,7 +3910,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -4071,8 +3932,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -4089,8 +3949,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -4107,15 +3966,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -4132,8 +3989,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -4197,7 +4053,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -4221,8 +4076,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -4255,7 +4109,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -4278,7 +4131,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -4310,7 +4162,6 @@
"type": "integer"
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -4362,7 +4213,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -4385,8 +4235,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -4403,8 +4252,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -4421,15 +4269,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -4446,8 +4292,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -4511,7 +4356,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -4535,8 +4379,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -4569,7 +4412,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -4592,7 +4434,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -4614,7 +4455,6 @@
"type": "integer"
}
},
- "additionalProperties": false,
"required": [
"id",
"position"
@@ -4671,7 +4511,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -4694,8 +4533,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -4712,8 +4550,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -4730,15 +4567,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -4755,8 +4590,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -4820,7 +4654,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -4844,8 +4677,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -4878,7 +4710,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -4901,7 +4732,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -4921,7 +4751,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"name"
],
@@ -4976,7 +4805,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -4999,8 +4827,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -5017,8 +4844,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -5035,15 +4861,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -5060,8 +4884,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -5125,7 +4948,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -5149,8 +4971,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -5183,7 +5004,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -5206,7 +5026,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -5226,7 +5045,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"name"
],
@@ -5281,7 +5099,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -5304,8 +5121,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -5322,8 +5138,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -5340,15 +5155,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -5365,8 +5178,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -5430,7 +5242,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -5454,8 +5265,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -5488,7 +5298,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -5511,7 +5320,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -5530,7 +5338,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -5582,7 +5389,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -5605,8 +5411,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -5623,8 +5428,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -5641,15 +5445,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -5666,8 +5468,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -5731,7 +5532,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -5755,8 +5555,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -5789,7 +5588,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -5812,7 +5610,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -5848,7 +5645,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"channel_id"
],
@@ -5903,7 +5699,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -5926,8 +5721,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -5944,8 +5738,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -5962,15 +5755,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -5987,8 +5778,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -6052,7 +5842,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -6076,8 +5865,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -6110,7 +5898,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -6133,7 +5920,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -6164,7 +5950,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"channel_id",
"description",
@@ -6179,7 +5964,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -6231,7 +6015,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -6254,8 +6037,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -6272,8 +6054,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -6290,15 +6071,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -6315,8 +6094,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -6380,7 +6158,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -6404,8 +6181,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -6438,7 +6214,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -6461,7 +6236,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -6481,7 +6255,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"channel_id",
"enabled"
@@ -6537,7 +6310,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -6560,8 +6332,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -6578,8 +6349,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -6596,15 +6366,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -6621,8 +6389,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -6686,7 +6453,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -6710,8 +6476,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -6744,7 +6509,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -6767,7 +6531,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -6790,7 +6553,6 @@
]
}
},
- "additionalProperties": false,
"required": [
"name"
],
@@ -6845,7 +6607,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -6868,8 +6629,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -6886,8 +6646,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -6904,15 +6663,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -6929,8 +6686,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -6994,7 +6750,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -7018,8 +6773,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -7052,7 +6806,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -7075,7 +6828,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -7103,7 +6855,6 @@
"format": "date-time"
}
},
- "additionalProperties": false,
"required": [
"connected_accounts",
"user"
@@ -7159,7 +6910,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -7182,8 +6932,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -7200,8 +6949,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -7218,15 +6966,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -7243,8 +6989,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -7308,7 +7053,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -7332,8 +7076,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -7366,7 +7109,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -7389,7 +7131,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -7412,7 +7153,6 @@
}
}
},
- "additionalProperties": false,
"required": [
"recipients"
],
@@ -7467,7 +7207,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -7490,8 +7229,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -7508,8 +7246,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -7526,15 +7263,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -7551,8 +7286,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -7616,7 +7350,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -7640,8 +7373,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -7674,7 +7406,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -7697,7 +7428,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -7744,7 +7474,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -7796,7 +7525,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -7819,8 +7547,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -7837,8 +7564,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -7855,15 +7581,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -7880,8 +7604,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -7945,7 +7668,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -7969,8 +7691,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -8003,7 +7724,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -8026,7 +7746,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -8049,7 +7768,6 @@
"type": "number"
}
},
- "additionalProperties": false,
"definitions": {
"ChannelPermissionOverwriteType": {
"enum": [
@@ -8101,7 +7819,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -8124,8 +7841,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -8142,8 +7858,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -8160,15 +7875,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -8185,8 +7898,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -8250,7 +7962,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -8274,8 +7985,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -8308,7 +8018,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -8331,7 +8040,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -8351,7 +8059,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"discriminator",
"username"
@@ -8407,7 +8114,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -8430,8 +8136,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -8448,8 +8153,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -8466,15 +8170,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -8491,8 +8193,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -8556,7 +8257,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -8580,8 +8280,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -8614,7 +8313,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -8637,7 +8335,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
@@ -8683,8 +8380,7 @@
"text": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"default_guilds_restricted": {
"type": "boolean"
@@ -8711,7 +8407,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"all"
]
@@ -8743,7 +8438,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"color",
"guild_ids",
@@ -8811,7 +8505,6 @@
"type": "integer"
}
},
- "additionalProperties": false,
"required": [
"afk_timeout",
"allow_accessibility_detection",
@@ -8896,7 +8589,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"text"
]
@@ -8919,8 +8611,7 @@
"url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"author": {
"type": "object",
@@ -8937,8 +8628,7 @@
"proxy_icon_url": {
"type": "string"
}
- },
- "additionalProperties": false
+ }
},
"fields": {
"type": "array",
@@ -8955,15 +8645,13 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"value"
]
}
}
- },
- "additionalProperties": false
+ }
},
"EmbedImage": {
"type": "object",
@@ -8980,8 +8668,7 @@
"width": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"ChannelModifySchema": {
"type": "object",
@@ -9045,7 +8732,6 @@
"type": "string"
}
},
- "additionalProperties": false,
"required": [
"allow",
"deny",
@@ -9069,8 +8755,7 @@
"default_auto_archive_duration": {
"type": "integer"
}
- },
- "additionalProperties": false
+ }
},
"UserPublic": {
"type": "object",
@@ -9103,7 +8788,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"bio",
"bot",
@@ -9126,7 +8810,6 @@
"type": "boolean"
}
},
- "additionalProperties": false,
"required": [
"name",
"type",
diff --git a/api/scripts/generate_schema.js b/api/scripts/generate_schema.js
index fc787c22..c12f6b1a 100644
--- a/api/scripts/generate_schema.js
+++ b/api/scripts/generate_schema.js
@@ -30,6 +30,15 @@ const Excluded = [
"supertest.Response"
];
+function modify(obj) {
+ delete obj.additionalProperties;
+ for (var k in obj) {
+ if (typeof obj[k] === "object" && obj[k] !== null) {
+ modify(obj[k]);
+ }
+ }
+}
+
function main() {
const program = TJS.getProgramFromFiles(walk(path.join(__dirname, "..", "src", "routes")), compilerOptions);
const generator = TJS.buildGenerator(program, settings);
@@ -47,6 +56,8 @@ function main() {
definitions = { ...definitions, [name]: { ...part } };
}
+ modify(definitions);
+
fs.writeFileSync(schemaPath, JSON.stringify(definitions, null, 4));
}
diff --git a/api/src/middlewares/Authentication.ts b/api/src/middlewares/Authentication.ts
index a300c786..5a082751 100644
--- a/api/src/middlewares/Authentication.ts
+++ b/api/src/middlewares/Authentication.ts
@@ -1,6 +1,6 @@
import { NextFunction, Request, Response } from "express";
import { HTTPError } from "lambert-server";
-import { checkToken, Config } from "@fosscord/util";
+import { checkToken, Config, Rights } from "@fosscord/util";
export const NO_AUTHORIZATION_ROUTES = [
"/auth/login",
@@ -21,6 +21,7 @@ declare global {
user_id: string;
user_bot: boolean;
token: string;
+ rights: Rights;
}
}
}
@@ -46,6 +47,7 @@ export async function Authentication(req: Request, res: Response, next: NextFunc
req.token = decoded;
req.user_id = decoded.id;
req.user_bot = user.bot;
+ req.rights = new Rights(Number(user.rights));
return next();
} catch (error: any) {
return next(new HTTPError(error?.toString(), 400));
diff --git a/api/src/routes/applications/#id/entitlements.ts b/api/src/routes/applications/#id/entitlements.ts
new file mode 100644
index 00000000..1152e500
--- /dev/null
+++ b/api/src/routes/applications/#id/entitlements.ts
@@ -0,0 +1,12 @@
+import { Router, Response, Request } from "express";
+import { route } from "@fosscord/api";
+
+const router = Router();
+
+router.get("/", route({}), (req: Request, res: Response) => {
+ // TODO:
+ //const { exclude_consumed } = req.query;
+ res.status(200).send([]);
+});
+
+export default router;
diff --git a/api/src/routes/auth/register.ts b/api/src/routes/auth/register.ts
index 9c058399..1344c994 100644
--- a/api/src/routes/auth/register.ts
+++ b/api/src/routes/auth/register.ts
@@ -50,6 +50,15 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re
const { register, security } = Config.get();
const ip = getIpAdress(req);
+ if (register.disabled) {
+ throw FieldErrors({
+ email: {
+ code: "DISABLED",
+ message: "registration is disabled on this instance"
+ }
+ });
+ }
+
if (register.blockProxies) {
if (isProxy(await IPAnalysis(ip))) {
console.log(`proxy ${ip} blocked from registration`);
@@ -202,6 +211,7 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re
disabled: false,
deleted: false,
email: email,
+ rights: "0",
nsfw_allowed: true, // TODO: depending on age
public_flags: "0",
flags: "0", // TODO: generate
diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts b/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts
index 6753e832..de0c01f1 100644
--- a/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts
+++ b/api/src/routes/channels/#channel_id/messages/#message_id/crosspost.ts
@@ -1,8 +1,30 @@
import { Router, Response, Request } from "express";
+import { route } from "@fosscord/api";
const router = Router();
-// TODO:
-// router.post("/", (req: Request, res: Response) => {});
+router.post("/", route({ permission: "MANAGE_MESSAGES" }), (req: Request, res: Response) => {
+ // TODO:
+ res.json({
+ id: "",
+ type: 0,
+ content: "",
+ channel_id: "",
+ author: {id: "",
+ username: "",
+ avatar: "",
+ discriminator: "", public_flags: 64},
+ attachments: [],
+ embeds: [],
+ mentions: [],
+ mention_roles: [],
+ pinned: false,
+ mention_everyone: false,
+ tts: false,
+ timestamp: "",
+ edited_timestamp: null,
+ flags: 1, components: []}).status(200);
+});
export default router;
+
diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts b/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
index f2b83d40..6b6a66b2 100644
--- a/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
+++ b/api/src/routes/channels/#channel_id/messages/#message_id/reactions.ts
@@ -124,7 +124,7 @@ router.put("/:emoji/:user_id", route({ permission: "READ_MESSAGE_HISTORY" }), as
already_added.count++;
} else message.reactions.push({ count: 1, emoji, user_ids: [req.user_id] });
- await Message.update({ id: message_id, channel_id }, message);
+ await message.save();
const member = channel.guild_id && (await Member.findOneOrFail({ id: req.user_id }));
@@ -165,7 +165,7 @@ router.delete("/:emoji/:user_id", route({}), async (req: Request, res: Response)
if (already_added.count <= 0) message.reactions.remove(already_added);
- await Message.update({ id: message_id, channel_id }, message);
+ await message.save();
await emitEvent({
event: "MESSAGE_REACTION_REMOVE",
diff --git a/api/src/routes/discoverable-guilds.ts b/api/src/routes/discoverable-guilds.ts
index f667eb2a..b626b084 100644
--- a/api/src/routes/discoverable-guilds.ts
+++ b/api/src/routes/discoverable-guilds.ts
@@ -1,16 +1,18 @@
-import { Guild } from "@fosscord/util";
+import { Guild, Config } from "@fosscord/util";
+
import { Router, Request, Response } from "express";
import { route } from "@fosscord/api";
+
const router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
const { limit } = req.params;
-
+ var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery;
// ! this only works using SQL querys
// TODO: implement this with default typeorm query
// const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) });
- const guilds = await Guild.find({ where: `"features" LIKE 'COMMUNITY'`, take: Math.abs(Number(limit)) });
+ const guilds = showAllGuilds ? await Guild.find({take: Math.abs(Number(limit || 20))}) : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 20)) });
res.send({ guilds: guilds });
});
diff --git a/api/src/routes/discovery.ts b/api/src/routes/discovery.ts
new file mode 100644
index 00000000..9e6e0164
--- /dev/null
+++ b/api/src/routes/discovery.ts
@@ -0,0 +1,12 @@
+import { Router, Response, Request } from "express";
+import { route } from "@fosscord/api";
+
+const router = Router();
+
+router.get("/categories", route({}), (req: Request, res: Response) => {
+ // TODO:
+ //const { locale, primary_only } = req.query;
+ res.json([]).status(200);
+});
+
+export default router;
diff --git a/api/src/routes/store/skus.ts b/api/src/routes/stage-instances.ts
index 7d0e12eb..411e95bf 100644
--- a/api/src/routes/store/skus.ts
+++ b/api/src/routes/stage-instances.ts
@@ -3,9 +3,8 @@ import { route } from "@fosscord/api";
const router: Router = Router();
-router.get("/skus/:id", route({}), async (req: Request, res: Response) => {
+router.get("/", route({}), async (req: Request, res: Response) => {
//TODO
- const { id } = req.params;
res.json([]).status(200);
});
diff --git a/api/src/routes/store/published-listings/applications.ts b/api/src/routes/store/published-listings/applications.ts
new file mode 100644
index 00000000..f06a01e4
--- /dev/null
+++ b/api/src/routes/store/published-listings/applications.ts
@@ -0,0 +1,79 @@
+import { Request, Response, Router } from "express";
+import { route } from "@fosscord/api";
+
+const router: Router = Router();
+
+router.get("/:id", route({}), async (req: Request, res: Response) => {
+ //TODO
+ const id = req.params.id;
+ res.json({
+ id: "",
+ summary: "",
+ sku: {
+ id: "",
+ type: 1,
+ dependent_sku_id: null,
+ application_id: "",
+ manifets_labels: [],
+ access_type: 2,
+ name: "",
+ features: [],
+ relase_date: "",
+ premium: false,
+ slug: "",
+ flags: 4,
+ genres: [],
+ legal_notice: "",
+ application: {
+ id: "",
+ name: "",
+ icon: "",
+ description: "",
+ summary: "",
+ cover_image: "",
+ primary_sku_id: "",
+ hook: true,
+ slug: "",
+ guild_id: "",
+ bot_public: "",
+ bot_require_code_grant: false,
+ verify_key: "",
+ publishers: [
+ {
+ id: "",
+ name: ""
+ }
+ ],
+ developers: [
+ {
+ id: "",
+ name: ""
+ }
+ ],
+ system_requirements: {},
+ show_age_gate: false,
+ price: {
+ amount: 0,
+ currency: "EUR"
+ },
+ locales: []
+ },
+ tagline: "",
+ description: "",
+ carousel_items: [
+ {
+ asset_id: ""
+ }
+ ],
+ header_logo_dark_theme: {}, //{id: "", size: 4665, mime_type: "image/gif", width 160, height: 160}
+ header_logo_light_theme: {},
+ box_art: {},
+ thumbnail: {},
+ header_background: {},
+ hero_background: {},
+ assets: []
+ }
+ }).status(200);
+});
+
+export default router;
diff --git a/api/src/routes/store/published-listings/applications/#id/subscription-plans.ts b/api/src/routes/store/published-listings/applications/#id/subscription-plans.ts
new file mode 100644
index 00000000..77f949d9
--- /dev/null
+++ b/api/src/routes/store/published-listings/applications/#id/subscription-plans.ts
@@ -0,0 +1,24 @@
+import { Request, Response, Router } from "express";
+import { route } from "@fosscord/api";
+
+const router: Router = Router();
+
+router.get("/", route({}), async (req: Request, res: Response) => {
+ //TODO
+ res.json([
+ {
+ id: "",
+ name: "",
+ interval: 1,
+ interval_count: 1,
+ tax_inclusive: true,
+ sku_id: "",
+ fallback_price: 499,
+ fallback_currency: "eur",
+ currency: "eur",
+ price: 4199,
+ price_tier: null
+ }]).status(200);
+});
+
+export default router;
diff --git a/api/src/routes/store/published-listings/skus.ts b/api/src/routes/store/published-listings/skus.ts
new file mode 100644
index 00000000..f06a01e4
--- /dev/null
+++ b/api/src/routes/store/published-listings/skus.ts
@@ -0,0 +1,79 @@
+import { Request, Response, Router } from "express";
+import { route } from "@fosscord/api";
+
+const router: Router = Router();
+
+router.get("/:id", route({}), async (req: Request, res: Response) => {
+ //TODO
+ const id = req.params.id;
+ res.json({
+ id: "",
+ summary: "",
+ sku: {
+ id: "",
+ type: 1,
+ dependent_sku_id: null,
+ application_id: "",
+ manifets_labels: [],
+ access_type: 2,
+ name: "",
+ features: [],
+ relase_date: "",
+ premium: false,
+ slug: "",
+ flags: 4,
+ genres: [],
+ legal_notice: "",
+ application: {
+ id: "",
+ name: "",
+ icon: "",
+ description: "",
+ summary: "",
+ cover_image: "",
+ primary_sku_id: "",
+ hook: true,
+ slug: "",
+ guild_id: "",
+ bot_public: "",
+ bot_require_code_grant: false,
+ verify_key: "",
+ publishers: [
+ {
+ id: "",
+ name: ""
+ }
+ ],
+ developers: [
+ {
+ id: "",
+ name: ""
+ }
+ ],
+ system_requirements: {},
+ show_age_gate: false,
+ price: {
+ amount: 0,
+ currency: "EUR"
+ },
+ locales: []
+ },
+ tagline: "",
+ description: "",
+ carousel_items: [
+ {
+ asset_id: ""
+ }
+ ],
+ header_logo_dark_theme: {}, //{id: "", size: 4665, mime_type: "image/gif", width 160, height: 160}
+ header_logo_light_theme: {},
+ box_art: {},
+ thumbnail: {},
+ header_background: {},
+ hero_background: {},
+ assets: []
+ }
+ }).status(200);
+});
+
+export default router;
diff --git a/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts b/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts
new file mode 100644
index 00000000..54c01607
--- /dev/null
+++ b/api/src/routes/store/published-listings/skus/#sku_id/subscription-plans.ts
@@ -0,0 +1,25 @@
+import { Request, Response, Router } from "express";
+import { route } from "@fosscord/api";
+
+const router: Router = Router();
+
+const skus = new Map([
+ ["521842865731534868", [{"id": "511651856145973248", "name": "Premium Monthly (Legacy)", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651860671627264", "name": "Premium Yearly (Legacy)", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521842865731534868", "currency": "usd", "price": 0, "price_tier": null}]],
+ ["521846918637420545", [{"id": "511651871736201216", "name": "Premium Classic Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651876987469824", "name": "Premium Classic Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521846918637420545", "currency": "usd", "price": 0, "price_tier": null}]],
+ ["521847234246082599", [{"id": "642251038925127690", "name": "Premium Quarterly", "interval": 1, "interval_count": 3, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651880837840896", "name": "Premium Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}, {"id": "511651885459963904", "name": "Premium Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "521847234246082599", "currency": "usd", "price": 0, "price_tier": null}]],
+ ["590663762298667008", [{"id": "590665532894740483", "name": "Server Boost Monthly", "interval": 1, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}, {"id": "590665538238152709", "name": "Server Boost Yearly", "interval": 2, "interval_count": 1, "tax_inclusive": true, "sku_id": "590663762298667008", "discount_price": 0, "currency": "usd", "price": 0, "price_tier": null}]],
+]);
+
+router.get("/", route({}), async (req: Request, res: Response) => {
+ // TODO: add the ability to add custom
+ const { sku_id } = req.params;
+
+ if(!skus.has(sku_id)) {
+ console.log(`Request for invalid SKU ${sku_id}! Please report this!`);
+ res.sendStatus(404);
+ } else {
+ res.json(skus.get(sku_id)).status(200);
+ }
+});
+
+export default router;
diff --git a/api/src/routes/users/@me/activities/statistics/applications.ts b/api/src/routes/users/@me/activities/statistics/applications.ts
new file mode 100644
index 00000000..834be35c
--- /dev/null
+++ b/api/src/routes/users/@me/activities/statistics/applications.ts
@@ -0,0 +1,11 @@
+import { Router, Response, Request } from "express";
+import { route } from "@fosscord/api";
+
+const router = Router();
+
+router.get("/", route({}), (req: Request, res: Response) => {
+ // TODO:
+ res.json([]).status(200)
+});
+
+export default router;
diff --git a/api/src/routes/users/@me/billing/payment-sources.ts b/api/src/routes/users/@me/billing/payment-sources.ts
new file mode 100644
index 00000000..834be35c
--- /dev/null
+++ b/api/src/routes/users/@me/billing/payment-sources.ts
@@ -0,0 +1,11 @@
+import { Router, Response, Request } from "express";
+import { route } from "@fosscord/api";
+
+const router = Router();
+
+router.get("/", route({}), (req: Request, res: Response) => {
+ // TODO:
+ res.json([]).status(200)
+});
+
+export default router;
diff --git a/api/src/routes/users/@me/email-settings.ts b/api/src/routes/users/@me/email-settings.ts
new file mode 100644
index 00000000..2d961a0e
--- /dev/null
+++ b/api/src/routes/users/@me/email-settings.ts
@@ -0,0 +1,19 @@
+import { Router, Response, Request } from "express";
+import { route } from "@fosscord/api";
+
+const router = Router();
+
+router.get("/", route({}), (req: Request, res: Response) => {
+ // TODO:
+ res.json({
+ categories: {
+ social: true,
+ communication: true,
+ tips: false,
+ updates_and_announcements: false,
+ recommendations_and_events: false },
+ initialized: false
+ }).status(200);
+});
+
+export default router;
diff --git a/api/src/routes/users/@me/entitlements.ts b/api/src/routes/users/@me/entitlements.ts
new file mode 100644
index 00000000..341e2b4c
--- /dev/null
+++ b/api/src/routes/users/@me/entitlements.ts
@@ -0,0 +1,11 @@
+import { Router, Response, Request } from "express";
+import { route } from "@fosscord/api";
+
+const router = Router();
+
+router.get("/gifts", route({}), (req: Request, res: Response) => {
+ // TODO:
+ res.json([]).status(200);
+});
+
+export default router;
diff --git a/api/src/routes/users/@me/guilds/premium/subscription-slots.ts b/api/src/routes/users/@me/guilds/premium/subscription-slots.ts
new file mode 100644
index 00000000..014df8af
--- /dev/null
+++ b/api/src/routes/users/@me/guilds/premium/subscription-slots.ts
@@ -0,0 +1,11 @@
+import { Router, Response, Request } from "express";
+import { route } from "@fosscord/api";
+
+const router = Router();
+
+router.get("/", route({}), (req: Request, res: Response) => {
+ // TODO:
+ res.json([]).status(200);
+});
+
+export default router;
diff --git a/api/src/routes/store/applications.ts b/api/src/routes/users/@me/notes.ts
index 352c1752..2ef27bc0 100644
--- a/api/src/routes/store/applications.ts
+++ b/api/src/routes/users/@me/notes.ts
@@ -3,10 +3,12 @@ import { route } from "@fosscord/api";
const router: Router = Router();
-router.get("/applications/:id", route({}), async (req: Request, res: Response) => {
+router.put("/:id", route({}), async (req: Request, res: Response) => {
//TODO
- const { id } = req.params;
- res.json([]).status(200);
+ res.json({
+ message: "400: Bad Request",
+ code: 0
+ }).status(400);
});
export default router;
diff --git a/api/src/util/route.ts b/api/src/util/route.ts
index 45882d8a..3e967e2a 100644
--- a/api/src/util/route.ts
+++ b/api/src/util/route.ts
@@ -1,4 +1,15 @@
-import { DiscordApiErrors, EVENT, Event, EventData, getPermission, PermissionResolvable, Permissions } from "@fosscord/util";
+import {
+ DiscordApiErrors,
+ EVENT,
+ Event,
+ EventData,
+ FosscordApiErrors,
+ getPermission,
+ PermissionResolvable,
+ Permissions,
+ RightResolvable,
+ Rights
+} from "@fosscord/util";
import { NextFunction, Request, Response } from "express";
import fs from "fs";
import path from "path";
@@ -33,6 +44,7 @@ export type RouteResponse = { status?: number; body?: `${string}Response`; heade
export interface RouteOptions {
permission?: PermissionResolvable;
+ right?: RightResolvable;
body?: `${string}Schema`; // typescript interface name
test?: {
response?: RouteResponse;
@@ -89,6 +101,13 @@ export function route(opts: RouteOptions) {
}
}
+ if (opts.right) {
+ const required = new Rights(opts.right);
+ if (!req.rights || !req.rights.has(required)) {
+ throw FosscordApiErrors.MISSING_RIGHTS.withParams(opts.right as string);
+ }
+ }
+
if (validate) {
const valid = validate(normalizeBody(req.body));
if (!valid) {
diff --git a/bundle/src/Server.ts b/bundle/src/Server.ts
index 62764e8e..3a56ee2e 100644
--- a/bundle/src/Server.ts
+++ b/bundle/src/Server.ts
@@ -38,9 +38,23 @@ async function main() {
'${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}',
endpointPrivate: `ws://localhost:${port}`,
...(!Config.get().gateway.endpointPublic && {
- endpointPublic: `http://localhost:${port}`,
+ endpointPublic: `ws://localhost:${port}`,
}),
},
+ // regions: {
+ // default: "fosscord",
+ // useDefaultAsOptimal: true,
+ // available: [
+ // {
+ // id: "fosscord",
+ // name: "Fosscord",
+ // endpoint: "127.0.0.1:3001",
+ // vip: false,
+ // custom: false,
+ // deprecated: false,
+ // },
+ // ],
+ // },
} as any);
await Promise.all([api.start(), cdn.start(), gateway.start()]);
diff --git a/gateway/package.json b/gateway/package.json
index d0292925..863d7f4e 100644
--- a/gateway/package.json
+++ b/gateway/package.json
@@ -4,7 +4,7 @@
"description": "",
"main": "dist/index.js",
"scripts": {
- "postinstall": "ts-patch install -s",
+ "postinstall": "npx ts-patch install -s",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npm run build && node dist/start.js",
"build": "npx tsc -b .",
diff --git a/gateway/src/Server.ts b/gateway/src/Server.ts
index 944174c7..b4e92a75 100644
--- a/gateway/src/Server.ts
+++ b/gateway/src/Server.ts
@@ -1,7 +1,7 @@
import "missing-native-js-functions";
import dotenv from "dotenv";
dotenv.config();
-import { closeDatabase, Config, initDatabase, initEvent, RabbitMQ } from "@fosscord/util";
+import { closeDatabase, Config, initDatabase, initEvent } from "@fosscord/util";
import { Server as WebSocketServer } from "ws";
import { Connection } from "./events/Connection";
import http from "http";
@@ -12,15 +12,24 @@ export class Server {
public server: http.Server;
public production: boolean;
- constructor({ port, server, production }: { port: number; server?: http.Server; production?: boolean }) {
+ constructor({
+ port,
+ server,
+ production,
+ }: {
+ port: number;
+ server?: http.Server;
+ production?: boolean;
+ }) {
this.port = port;
this.production = production || false;
if (server) this.server = server;
- else
+ else {
this.server = http.createServer(function (req, res) {
res.writeHead(200).end("Online");
});
+ }
this.server.on("upgrade", (request, socket, head) => {
console.log("socket requests upgrade", request.url);
diff --git a/gateway/src/events/Connection.ts b/gateway/src/events/Connection.ts
index 85f92b77..f84f9d9b 100644
--- a/gateway/src/events/Connection.ts
+++ b/gateway/src/events/Connection.ts
@@ -35,8 +35,11 @@ export async function Connection(
// @ts-ignore
socket.encoding = searchParams.get("encoding") || "json";
if (!["json", "etf"].includes(socket.encoding)) {
- if (socket.encoding === "etf" && erlpack)
- throw new Error("Erlpack is not installed: 'npm i -D erlpack'");
+ if (socket.encoding === "etf" && erlpack) {
+ throw new Error(
+ "Erlpack is not installed: 'npm i @yukikaze-bot/erlpack'"
+ );
+ }
return socket.close(CLOSECODES.Decode_error);
}
diff --git a/gateway/src/util/setHeartbeat.ts b/gateway/src/util/Heartbeat.ts
index f6871cfe..f6871cfe 100644
--- a/gateway/src/util/setHeartbeat.ts
+++ b/gateway/src/util/Heartbeat.ts
diff --git a/gateway/src/util/WebSocket.ts b/gateway/src/util/WebSocket.ts
index b80265a7..49626b2a 100644
--- a/gateway/src/util/WebSocket.ts
+++ b/gateway/src/util/WebSocket.ts
@@ -1,7 +1,6 @@
import { Intents, Permissions } from "@fosscord/util";
import WS from "ws";
import { Deflate } from "zlib";
-import { Channel } from "amqplib";
export interface WebSocket extends WS {
version: number;
diff --git a/gateway/src/util/index.ts b/gateway/src/util/index.ts
index 27af5813..0be5ecee 100644
--- a/gateway/src/util/index.ts
+++ b/gateway/src/util/index.ts
@@ -1,5 +1,5 @@
export * from "./Constants";
export * from "./Send";
export * from "./SessionUtils";
-export * from "./setHeartbeat";
+export * from "./Heartbeat";
export * from "./WebSocket";
diff --git a/gateway/tsconfig.json b/gateway/tsconfig.json
index dd066383..7143c8a3 100644
--- a/gateway/tsconfig.json
+++ b/gateway/tsconfig.json
@@ -71,8 +71,7 @@
"baseUrl": ".",
"paths": {
"@fosscord/gateway": ["src/index"],
- "@fosscord/gateway/*": ["src/*"],
- "@fosscord/util/*": ["../util/src/*"]
+ "@fosscord/gateway/*": ["src/*"]
},
"plugins": [{ "transform": "@zerollup/ts-transform-paths" }]
}
diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts
index 6d9db470..edce92a9 100644
--- a/util/src/entities/Config.ts
+++ b/util/src/entities/Config.ts
@@ -125,6 +125,7 @@ export interface ConfigValue {
required: boolean;
minimum: number; // in years
};
+ disabled: boolean;
requireCaptcha: boolean;
requireInvite: boolean;
allowNewRegistration: boolean;
@@ -143,6 +144,10 @@ export interface ConfigValue {
useDefaultAsOptimal: boolean;
available: Region[];
};
+
+ guild: {
+ showAllGuildsInDiscovery: boolean;
+ };
rabbitmq: {
host: string | null;
};
@@ -266,6 +271,7 @@ export const DefaultConfigOptions: ConfigValue = {
required: false,
minimum: 13,
},
+ disabled: false,
requireInvite: false,
requireCaptcha: true,
allowNewRegistration: true,
@@ -293,6 +299,10 @@ export const DefaultConfigOptions: ConfigValue = {
},
],
},
+
+ guild: {
+ showAllGuildsInDiscovery: false,
+ },
rabbitmq: {
host: null,
},
diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts
index c4901693..04c3c7aa 100644
--- a/util/src/entities/Message.ts
+++ b/util/src/entities/Message.ts
@@ -74,9 +74,7 @@ export class Message extends BaseClass {
author_id: string;
@JoinColumn({ name: "author_id", referencedColumnName: "id" })
- @ManyToOne(() => User, {
- onDelete: "CASCADE",
- })
+ @ManyToOne(() => User)
author?: User;
@Column({ nullable: true })
@@ -120,7 +118,7 @@ export class Message extends BaseClass {
mention_everyone?: boolean;
@JoinTable({ name: "message_user_mentions" })
- @ManyToMany(() => User, { orphanedRowAction: "delete", onDelete: "CASCADE", cascade: true })
+ @ManyToMany(() => User)
mentions: User[];
@JoinTable({ name: "message_role_mentions" })
diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts
index 5af755ed..b6f3723c 100644
--- a/util/src/entities/User.ts
+++ b/util/src/entities/User.ts
@@ -3,7 +3,6 @@ import { BaseClass } from "./BaseClass";
import { BitField } from "../util/BitField";
import { Relationship } from "./Relationship";
import { ConnectedAccount } from "./ConnectedAccount";
-import { HTTPError } from "lambert-server";
export enum PublicUserEnum {
username,
@@ -126,6 +125,9 @@ export class User extends BaseClass {
@Column()
public_flags: number;
+ @Column()
+ rights: string; // Rights
+
@JoinColumn({ name: "relationship_ids" })
@OneToMany(() => Relationship, (relationship: Relationship) => relationship.from, {
cascade: true,
@@ -278,5 +280,7 @@ export class UserFlags extends BitField {
UNDERAGE_DELETED: BigInt(1) << BigInt(15),
VERIFIED_BOT: BigInt(1) << BigInt(16),
EARLY_VERIFIED_BOT_DEVELOPER: BigInt(1) << BigInt(17),
+ CERTIFIED_MODERATOR: BigInt(1) << BigInt(18),
+ BOT_HTTP_INTERACTIONS: BigInt(1) << BigInt(19),
};
}
diff --git a/util/src/util/BitField.ts b/util/src/util/BitField.ts
index ac19763e..fb887e05 100644
--- a/util/src/util/BitField.ts
+++ b/util/src/util/BitField.ts
@@ -141,3 +141,7 @@ export class BitField {
throw new RangeError("BITFIELD_INVALID: " + bit);
}
}
+
+export function BitFlag(x: bigint | number) {
+ return BigInt(1) << BigInt(x);
+}
diff --git a/util/src/util/Config.ts b/util/src/util/Config.ts
index 6a9e0e5a..255f425d 100644
--- a/util/src/util/Config.ts
+++ b/util/src/util/Config.ts
@@ -21,7 +21,6 @@ export const Config = {
set: function set(val: Partial<ConfigValue>) {
if (!config || !val) return;
config = val.merge(config);
- console.log(config);
return applyConfig(config);
},
diff --git a/util/src/util/Constants.ts b/util/src/util/Constants.ts
index d2cc5130..5fdf5bc0 100644
--- a/util/src/util/Constants.ts
+++ b/util/src/util/Constants.ts
@@ -726,7 +726,9 @@ export const DiscordApiErrors = {
/**
* An error encountered while performing an API request (Fosscord only). Here are the potential errors:
*/
-export const FosscordApiErrors = {};
+export const FosscordApiErrors = {
+ MISSING_RIGHTS: new ApiError("You lack rights to perform that action ({})", 50013, undefined, [""]),
+};
/**
* The value set for a guild's default message notifications, e.g. `ALL`. Here are the available types:
diff --git a/util/src/util/Permissions.ts b/util/src/util/Permissions.ts
index f0012c96..e5459ab5 100644
--- a/util/src/util/Permissions.ts
+++ b/util/src/util/Permissions.ts
@@ -3,8 +3,7 @@
import { Channel, ChannelPermissionOverwrite, Guild, Member, Role } from "../entities";
import { BitField } from "./BitField";
import "missing-native-js-functions";
-import { BitFieldResolvable } from ".";
-// TODO: check role hierarchy permission
+import { BitFieldResolvable, BitFlag } from "./BitField";
var HTTPError: any;
@@ -32,44 +31,44 @@ export class Permissions extends BitField {
}
static FLAGS = {
- CREATE_INSTANT_INVITE: BigInt(1) << BigInt(0),
- KICK_MEMBERS: BigInt(1) << BigInt(1),
- BAN_MEMBERS: BigInt(1) << BigInt(2),
- ADMINISTRATOR: BigInt(1) << BigInt(3),
- MANAGE_CHANNELS: BigInt(1) << BigInt(4),
- MANAGE_GUILD: BigInt(1) << BigInt(5),
- ADD_REACTIONS: BigInt(1) << BigInt(6),
- VIEW_AUDIT_LOG: BigInt(1) << BigInt(7),
- PRIORITY_SPEAKER: BigInt(1) << BigInt(8),
- STREAM: BigInt(1) << BigInt(9),
- VIEW_CHANNEL: BigInt(1) << BigInt(10),
- SEND_MESSAGES: BigInt(1) << BigInt(11),
- SEND_TTS_MESSAGES: BigInt(1) << BigInt(12),
- MANAGE_MESSAGES: BigInt(1) << BigInt(13),
- EMBED_LINKS: BigInt(1) << BigInt(14),
- ATTACH_FILES: BigInt(1) << BigInt(15),
- READ_MESSAGE_HISTORY: BigInt(1) << BigInt(16),
- MENTION_EVERYONE: BigInt(1) << BigInt(17),
- USE_EXTERNAL_EMOJIS: BigInt(1) << BigInt(18),
- VIEW_GUILD_INSIGHTS: BigInt(1) << BigInt(19),
- CONNECT: BigInt(1) << BigInt(20),
- SPEAK: BigInt(1) << BigInt(21),
- MUTE_MEMBERS: BigInt(1) << BigInt(22),
- DEAFEN_MEMBERS: BigInt(1) << BigInt(23),
- MOVE_MEMBERS: BigInt(1) << BigInt(24),
- USE_VAD: BigInt(1) << BigInt(25),
- CHANGE_NICKNAME: BigInt(1) << BigInt(26),
- MANAGE_NICKNAMES: BigInt(1) << BigInt(27),
- MANAGE_ROLES: BigInt(1) << BigInt(28),
- MANAGE_WEBHOOKS: BigInt(1) << BigInt(29),
- MANAGE_EMOJIS_AND_STICKERS: BigInt(1) << BigInt(30),
- USE_APPLICATION_COMMANDS: BigInt(1) << BigInt(31),
- REQUEST_TO_SPEAK: BigInt(1) << BigInt(32),
+ CREATE_INSTANT_INVITE: BitFlag(0),
+ KICK_MEMBERS: BitFlag(1),
+ BAN_MEMBERS: BitFlag(2),
+ ADMINISTRATOR: BitFlag(3),
+ MANAGE_CHANNELS: BitFlag(4),
+ MANAGE_GUILD: BitFlag(5),
+ ADD_REACTIONS: BitFlag(6),
+ VIEW_AUDIT_LOG: BitFlag(7),
+ PRIORITY_SPEAKER: BitFlag(8),
+ STREAM: BitFlag(9),
+ VIEW_CHANNEL: BitFlag(10),
+ SEND_MESSAGES: BitFlag(11),
+ SEND_TTS_MESSAGES: BitFlag(12),
+ MANAGE_MESSAGES: BitFlag(13),
+ EMBED_LINKS: BitFlag(14),
+ ATTACH_FILES: BitFlag(15),
+ READ_MESSAGE_HISTORY: BitFlag(16),
+ MENTION_EVERYONE: BitFlag(17),
+ USE_EXTERNAL_EMOJIS: BitFlag(18),
+ VIEW_GUILD_INSIGHTS: BitFlag(19),
+ CONNECT: BitFlag(20),
+ SPEAK: BitFlag(21),
+ MUTE_MEMBERS: BitFlag(22),
+ DEAFEN_MEMBERS: BitFlag(23),
+ MOVE_MEMBERS: BitFlag(24),
+ USE_VAD: BitFlag(25),
+ CHANGE_NICKNAME: BitFlag(26),
+ MANAGE_NICKNAMES: BitFlag(27),
+ MANAGE_ROLES: BitFlag(28),
+ MANAGE_WEBHOOKS: BitFlag(29),
+ MANAGE_EMOJIS_AND_STICKERS: BitFlag(30),
+ USE_APPLICATION_COMMANDS: BitFlag(31),
+ REQUEST_TO_SPEAK: BitFlag(32),
// TODO: what is permission 33?
- MANAGE_THREADS: BigInt(1) << BigInt(34),
- USE_PUBLIC_THREADS: BigInt(1) << BigInt(35),
- USE_PRIVATE_THREADS: BigInt(1) << BigInt(36),
- USE_EXTERNAL_STICKERS: BigInt(1) << BigInt(37),
+ MANAGE_THREADS: BitFlag(34),
+ USE_PUBLIC_THREADS: BitFlag(35),
+ USE_PRIVATE_THREADS: BitFlag(36),
+ USE_EXTERNAL_STICKERS: BitFlag(37),
/**
* CUSTOM PERMISSIONS ideas:
diff --git a/util/src/util/Rights.ts b/util/src/util/Rights.ts
new file mode 100644
index 00000000..a266e4f7
--- /dev/null
+++ b/util/src/util/Rights.ts
@@ -0,0 +1,73 @@
+import { BitField } from "./BitField";
+import "missing-native-js-functions";
+import { BitFieldResolvable, BitFlag } from "./BitField";
+
+var HTTPError: any;
+
+try {
+ HTTPError = require("lambert-server").HTTPError;
+} catch (e) {
+ HTTPError = Error;
+}
+
+export type RightResolvable = bigint | number | Rights | RightResolvable[] | RightString;
+
+type RightString = keyof typeof Rights.FLAGS;
+// TODO: just like roles for members, users should have privilidges which combine multiple rights into one and make it easy to assign
+
+export class Rights extends BitField {
+ constructor(bits: BitFieldResolvable = 0) {
+ super(bits);
+ if (this.bitfield & Rights.FLAGS.OPERATOR) {
+ this.bitfield = ALL_RIGHTS;
+ }
+ }
+
+ static FLAGS = {
+ OPERATOR: BitFlag(0), // has all rights
+ MANAGE_APPLICATIONS: BitFlag(1),
+ MANAGE_GUILDS: BitFlag(2),
+ MANAGE_MESSAGES: BitFlag(3), // Can't see other messages but delete/edit them in channels that they can see
+ MANAGE_RATE_LIMITS: BitFlag(4),
+ MANAGE_ROUTING: BitFlag(5), // can create custom message routes to any channel/guild
+ MANAGE_TICKETS: BitFlag(6),
+ MANAGE_USERS: BitFlag(7),
+ ADD_MEMBERS: BitFlag(8), // can manually add any members in their guilds
+ BYPASS_RATE_LIMITS: BitFlag(9),
+ CREATE_APPLICATIONS: BitFlag(10),
+ CREATE_CHANNELS: BitFlag(11),
+ CREATE_DMS: BitFlag(12),
+ CREATE_DM_GROUPS: BitFlag(13),
+ CREATE_GUILDS: BitFlag(14),
+ CREATE_INVITES: BitFlag(15),
+ CREATE_ROLES: BitFlag(16),
+ CREATE_TEMPLATES: BitFlag(17),
+ CREATE_WEBHOOKS: BitFlag(18),
+ JOIN_GUILDS: BitFlag(19),
+ PIN_MESSAGES: BitFlag(20),
+ SELF_ADD_REACTIONS: BitFlag(21),
+ SELF_DELETE_MESSAGES: BitFlag(22),
+ SELF_EDIT_MESSAGES: BitFlag(23),
+ SELF_EDIT_NAME: BitFlag(24),
+ SEND_MESSAGES: BitFlag(25),
+ USE_SCREEN: BitFlag(26),
+ USE_VIDEO: BitFlag(27),
+ USE_VOICE: BitFlag(28),
+ };
+
+ any(permission: RightResolvable, checkOperator = true) {
+ return (checkOperator && super.any(Rights.FLAGS.OPERATOR)) || super.any(permission);
+ }
+
+ has(permission: RightResolvable, checkOperator = true) {
+ return (checkOperator && super.has(Rights.FLAGS.OPERATOR)) || super.has(permission);
+ }
+
+ hasThrow(permission: RightResolvable) {
+ if (this.has(permission)) return true;
+ // @ts-ignore
+ throw new HTTPError(`You are missing the following rights ${permission}`, 403);
+ }
+}
+
+const ALL_RIGHTS = Object.values(Rights.FLAGS).reduce((total, val) => total | val, BigInt(0));
diff --git a/util/src/util/Token.ts b/util/src/util/Token.ts
index 111d59a2..7c4cc61d 100644
--- a/util/src/util/Token.ts
+++ b/util/src/util/Token.ts
@@ -10,7 +10,10 @@ export function checkToken(token: string, jwtSecret: string): Promise<any> {
jwt.verify(token, jwtSecret, JWTOptions, async (err, decoded: any) => {
if (err || !decoded) return rej("Invalid Token");
- const user = await User.findOne({ id: decoded.id }, { select: ["data", "bot", "disabled", "deleted"] });
+ const user = await User.findOne(
+ { id: decoded.id },
+ { select: ["data", "bot", "disabled", "deleted", "rights"] }
+ );
if (!user) return rej("Invalid Token");
// we need to round it to seconds as it saved as seconds in jwt iat and valid_tokens_since is stored in milliseconds
if (decoded.iat * 1000 < new Date(user.data.valid_tokens_since).setSeconds(0, 0))
diff --git a/util/src/util/index.ts b/util/src/util/index.ts
index d73bf4ca..9c51d3b8 100644
--- a/util/src/util/index.ts
+++ b/util/src/util/index.ts
@@ -12,6 +12,7 @@ export * from "./MessageFlags";
export * from "./Permissions";
export * from "./RabbitMQ";
export * from "./Regex";
+export * from "./Rights";
export * from "./Snowflake";
export * from "./String";
export * from "./Array";
|