diff --git a/api/assets/schemas.json b/api/assets/schemas.json
index 76ad3b16..023f2092 100644
--- a/api/assets/schemas.json
+++ b/api/assets/schemas.json
@@ -1,73 +1,73 @@
{
- "RegisterSchema": {
+ "LoginSchema": {
"type": "object",
"properties": {
- "username": {
- "minLength": 2,
- "maxLength": 32,
+ "login": {
"type": "string"
},
"password": {
- "minLength": 1,
- "maxLength": 72,
"type": "string"
},
- "consent": {
+ "undelete": {
"type": "boolean"
},
- "email": {
- "format": "email",
- "type": "string"
- },
- "fingerprint": {
- "type": "string"
- },
- "invite": {
+ "captcha_key": {
"type": "string"
},
- "date_of_birth": {
+ "login_source": {
"type": "string"
},
"gift_code_sku_id": {
"type": "string"
- },
- "captcha_key": {
- "type": "string"
}
},
"additionalProperties": false,
"required": [
- "consent",
- "username"
+ "login",
+ "password"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
- "LoginSchema": {
+ "RegisterSchema": {
"type": "object",
"properties": {
- "login": {
+ "username": {
+ "minLength": 2,
+ "maxLength": 32,
"type": "string"
},
"password": {
+ "minLength": 1,
+ "maxLength": 72,
"type": "string"
},
- "undelete": {
+ "consent": {
"type": "boolean"
},
- "captcha_key": {
+ "email": {
+ "format": "email",
"type": "string"
},
- "login_source": {
+ "fingerprint": {
+ "type": "string"
+ },
+ "invite": {
+ "type": "string"
+ },
+ "date_of_birth": {
"type": "string"
},
"gift_code_sku_id": {
"type": "string"
+ },
+ "captcha_key": {
+ "type": "string"
}
},
"additionalProperties": false,
"required": [
- "login",
- "password"
+ "consent",
+ "username"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
@@ -127,10 +127,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -353,10 +353,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -727,10 +727,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -1050,10 +1050,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -1352,10 +1352,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -1657,10 +1657,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -1758,10 +1758,10 @@
"type": "object",
"properties": {
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
},
"id": {
"type": "string"
@@ -1971,10 +1971,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -2278,10 +2278,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -2580,10 +2580,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -2894,10 +2894,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -3221,10 +3221,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -3587,10 +3587,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -3889,10 +3889,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -4191,10 +4191,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -4505,10 +4505,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -4814,10 +4814,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -5119,10 +5119,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -5424,10 +5424,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -5725,10 +5725,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -6046,10 +6046,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -6374,10 +6374,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -6680,10 +6680,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -6988,10 +6988,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -7302,10 +7302,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -7610,10 +7610,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -7939,10 +7939,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -8244,10 +8244,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -8550,10 +8550,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
@@ -9039,10 +9039,10 @@
"$ref": "#/definitions/ChannelPermissionOverwriteType"
},
"allow": {
- "type": "bigint"
+ "type": "string"
},
"deny": {
- "type": "bigint"
+ "type": "string"
}
},
"additionalProperties": false,
diff --git a/api/package.json b/api/package.json
index cc47a45a..8fc55e94 100644
--- a/api/package.json
+++ b/api/package.json
@@ -14,8 +14,8 @@
"dev": "tsnd --respawn src/start.ts",
"patch": "ts-patch install -s && npx patch-package",
"postinstall": "npm run patch",
- "generate:docs": "node scripts/generate_openapi.ts",
- "generate:schema": "node scripts/generate_schema.ts"
+ "generate:docs": "node scripts/generate_openapi",
+ "generate:schema": "node scripts/generate_schema"
},
"repository": {
"type": "git",
diff --git a/api/scripts/generate_schema.js b/api/scripts/generate_schema.js
index 22d0b02e..fc787c22 100644
--- a/api/scripts/generate_schema.js
+++ b/api/scripts/generate_schema.js
@@ -1,9 +1,9 @@
// https://mermade.github.io/openapi-gui/#
// https://editor.swagger.io/
-import path from "path";
-import fs from "fs";
-import * as TJS from "typescript-json-schema";
-import "missing-native-js-functions";
+const path = require("path");
+const fs = require("fs");
+const TJS = require("typescript-json-schema");
+require("missing-native-js-functions");
const schemaPath = path.join(__dirname, "..", "assets", "schemas.json");
const settings = {
diff --git a/api/src/routes/channels/#channel_id/index.ts b/api/src/routes/channels/#channel_id/index.ts
index 61c851e8..2fca4fdf 100644
--- a/api/src/routes/channels/#channel_id/index.ts
+++ b/api/src/routes/channels/#channel_id/index.ts
@@ -62,8 +62,8 @@ export interface ChannelModifySchema {
permission_overwrites?: {
id: string;
type: ChannelPermissionOverwriteType;
- allow: bigint;
- deny: bigint;
+ allow: string;
+ deny: string;
}[];
parent_id?: string;
id?: string; // is not used (only for guild create)
diff --git a/api/src/routes/channels/#channel_id/permissions.ts b/api/src/routes/channels/#channel_id/permissions.ts
index bc7ad5b8..6ebf721a 100644
--- a/api/src/routes/channels/#channel_id/permissions.ts
+++ b/api/src/routes/channels/#channel_id/permissions.ts
@@ -1,4 +1,13 @@
-import { Channel, ChannelPermissionOverwrite, ChannelUpdateEvent, emitEvent, getPermission, Member, Role } from "@fosscord/util";
+import {
+ Channel,
+ ChannelPermissionOverwrite,
+ ChannelPermissionOverwriteType,
+ ChannelUpdateEvent,
+ emitEvent,
+ getPermission,
+ Member,
+ Role
+} from "@fosscord/util";
import { Router, Response, Request } from "express";
import { HTTPError } from "lambert-server";
@@ -14,7 +23,7 @@ router.put(
route({ body: "ChannelPermissionOverwriteSchema", permission: "MANAGE_ROLES" }),
async (req: Request, res: Response) => {
const { channel_id, overwrite_id } = req.params;
- const body = req.body as { allow: bigint; deny: bigint; type: number; id: string };
+ const body = req.body as ChannelPermissionOverwriteSchema;
var channel = await Channel.findOneOrFail({ id: channel_id });
if (!channel.guild_id) throw new HTTPError("Channel not found", 404);
@@ -31,14 +40,12 @@ router.put(
// @ts-ignore
overwrite = {
id: overwrite_id,
- type: body.type,
- allow: body.allow,
- deny: body.deny
+ type: body.type
};
channel.permission_overwrites!.push(overwrite);
}
- overwrite.allow = body.allow;
- overwrite.deny = body.deny;
+ overwrite.allow = String(req.permission!.bitfield & (BigInt(body.allow) || 0n));
+ overwrite.deny = String(req.permission!.bitfield & (BigInt(body.deny) || 0n));
await Promise.all([
channel.save(),
diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts
index ece82bd0..1644b265 100644
--- a/util/src/entities/Channel.ts
+++ b/util/src/entities/Channel.ts
@@ -320,8 +320,8 @@ export class Channel extends BaseClass {
}
export interface ChannelPermissionOverwrite {
- allow: bigint; // for bitfields we use bigints
- deny: bigint; // for bitfields we use bigints
+ allow: string;
+ deny: string;
id: string;
type: ChannelPermissionOverwriteType;
}
|