From 44859db499f080e3a341f3e7fa5e44611fc2f887 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Fri, 12 Aug 2022 01:46:42 +0200 Subject: Push local state... --- gateway/src/opcodes/Identify.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gateway/src/opcodes/Identify.ts') diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts index 03fff796..4e275592 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts @@ -18,6 +18,7 @@ import { PrivateSessionProjection, MemberPrivateProjection, PresenceUpdateEvent, + UserSettings, } from "@fosscord/util"; import { Send } from "../util/Send"; import { CLOSECODES, OPCODES } from "../util/Constants"; @@ -56,7 +57,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { await Promise.all([ User.findOneOrFail({ where: { id: this.user_id }, - relations: ["relationships", "relationships.to"], + relations: ["relationships", "relationships.to", "settings"], select: [...PrivateUserProjection, "relationships"], }), ReadState.find({ where: { user_id: this.user_id } }), @@ -101,6 +102,10 @@ export async function onIdentify(this: WebSocket, data: Payload) { ]); if (!user) return this.close(CLOSECODES.Authentication_failed); + if (!user.settings) { + user.settings = new UserSettings(); + await user.settings.save(); + } if (!identify.intents) identify.intents = BigInt("0x6ffffffff"); this.intents = new Intents(identify.intents); -- cgit 1.5.1 From 1d52b0d0721094d7f8dfaabddedd9f08a5e456a5 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Fri, 12 Aug 2022 03:24:51 +0200 Subject: Fix updated client stuff... --- api/assets/schemas.json | 162 +++++--- api/src/routes/channels/#channel_id/index.ts | 2 + api/src/routes/channels/#channel_id/invites.ts | 2 +- api/src/routes/channels/#channel_id/webhooks.ts | 3 +- api/src/util/handlers/route.ts | 5 + bundle/package.json | 3 +- bundle/scripts/update_schemas.js | 2 +- env-vars.md | 3 +- gateway/src/opcodes/Identify.ts | 3 +- util/src/entities/BaseClass.ts | 2 +- util/src/entities/Channel.ts | 7 + util/src/entities/User.ts | 6 +- .../mariadb/1660265930624-CodeCleanup5.ts | 53 +++ .../postgres/1660265907544-CodeCleanup5.ts | 26 ++ .../sqlite/1660260539853-CodeCleanup4.ts | 459 --------------------- 15 files changed, 218 insertions(+), 520 deletions(-) create mode 100644 util/src/migrations/mariadb/1660265930624-CodeCleanup5.ts create mode 100644 util/src/migrations/postgres/1660265907544-CodeCleanup5.ts delete mode 100644 util/src/migrations/sqlite/1660260539853-CodeCleanup4.ts (limited to 'gateway/src/opcodes/Identify.ts') diff --git a/api/assets/schemas.json b/api/assets/schemas.json index 00819e7c..d8576514 100644 --- a/api/assets/schemas.json +++ b/api/assets/schemas.json @@ -552,6 +552,12 @@ }, "default_auto_archive_duration": { "type": "integer" + }, + "flags": { + "type": "integer" + }, + "default_thread_rate_limit_per_user": { + "type": "integer" } }, "additionalProperties": false, @@ -695,7 +701,6 @@ }, "additionalProperties": false, "required": [ - "avatar", "name" ], "$schema": "http://json-schema.org/draft-07/schema#" @@ -1028,6 +1033,12 @@ }, "default_auto_archive_duration": { "type": "integer" + }, + "flags": { + "type": "integer" + }, + "default_thread_rate_limit_per_user": { + "type": "integer" } }, "additionalProperties": false @@ -1094,6 +1105,9 @@ "preferred_locale": { "type": "string" }, + "premium_progress_bar_enabled": { + "type": "boolean" + }, "region": { "type": "string" }, @@ -1651,6 +1665,9 @@ "UserSettingsSchema": { "type": "object", "properties": { + "id": { + "type": "string" + }, "afk_timeout": { "type": "integer" }, @@ -1672,22 +1689,7 @@ "custom_status": { "anyOf": [ { - "type": "object", - "properties": { - "emoji_id": { - "type": "string" - }, - "emoji_name": { - "type": "string" - }, - "expires_at": { - "type": "integer" - }, - "text": { - "type": "string" - } - }, - "additionalProperties": false + "$ref": "#/definitions/CustomStatus" }, { "type": "null" @@ -1713,16 +1715,7 @@ "type": "integer" }, "friend_source_flags": { - "type": "object", - "properties": { - "all": { - "type": "boolean" - } - }, - "additionalProperties": false, - "required": [ - "all" - ] + "$ref": "#/definitions/FriendSourceFlags" }, "gateway_connected": { "type": "boolean" @@ -1733,31 +1726,7 @@ "guild_folders": { "type": "array", "items": { - "type": "object", - "properties": { - "color": { - "type": "integer" - }, - "guild_ids": { - "type": "array", - "items": { - "type": "string" - } - }, - "id": { - "type": "integer" - }, - "name": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "color", - "guild_ids", - "id", - "name" - ] + "$ref": "#/definitions/GuildFolder" } }, "guild_positions": { @@ -1818,9 +1787,98 @@ }, "timezone_offset": { "type": "integer" + }, + "hasId": { + "description": "Checks if entity has an id.\nIf entity composite compose ids, it will check them all.", + "type": "object", + "additionalProperties": false + }, + "save": { + "description": "Saves current entity in the database.\nIf entity does not exist in the database then inserts, otherwise updates.", + "type": "object", + "additionalProperties": false + }, + "remove": { + "description": "Removes current entity from the database.", + "type": "object", + "additionalProperties": false + }, + "softRemove": { + "description": "Records the delete date of current entity.", + "type": "object", + "additionalProperties": false + }, + "recover": { + "description": "Recovers a given entity in the database.", + "type": "object", + "additionalProperties": false + }, + "reload": { + "description": "Reloads entity data from the database.", + "type": "object", + "additionalProperties": false } }, "additionalProperties": false, + "definitions": { + "CustomStatus": { + "type": "object", + "properties": { + "emoji_id": { + "type": "string" + }, + "emoji_name": { + "type": "string" + }, + "expires_at": { + "type": "integer" + }, + "text": { + "type": "string" + } + }, + "additionalProperties": false + }, + "FriendSourceFlags": { + "type": "object", + "properties": { + "all": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "all" + ] + }, + "GuildFolder": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "color", + "guild_ids", + "id", + "name" + ] + } + }, "$schema": "http://json-schema.org/draft-07/schema#" } } \ No newline at end of file diff --git a/api/src/routes/channels/#channel_id/index.ts b/api/src/routes/channels/#channel_id/index.ts index 68b52be6..70c34f05 100644 --- a/api/src/routes/channels/#channel_id/index.ts +++ b/api/src/routes/channels/#channel_id/index.ts @@ -71,6 +71,8 @@ export interface ChannelModifySchema { nsfw?: boolean; rtc_region?: string; default_auto_archive_duration?: number; + flags?: number; + default_thread_rate_limit_per_user?: number; } router.patch("/", route({ body: "ChannelModifySchema", permission: "MANAGE_CHANNELS" }), async (req: Request, res: Response) => { diff --git a/api/src/routes/channels/#channel_id/invites.ts b/api/src/routes/channels/#channel_id/invites.ts index a53b1de4..c0279f49 100644 --- a/api/src/routes/channels/#channel_id/invites.ts +++ b/api/src/routes/channels/#channel_id/invites.ts @@ -36,7 +36,7 @@ router.post("/", route({ body: "InviteCreateSchema", permission: "CREATE_INSTANT const invite = await OrmUtils.mergeDeep(new Invite(),{ code: random(), - temporary: req.body.temporary, + temporary: req.body.temporary || true, uses: 0, max_uses: req.body.max_uses, max_age: req.body.max_age, diff --git a/api/src/routes/channels/#channel_id/webhooks.ts b/api/src/routes/channels/#channel_id/webhooks.ts index 8f0e0a7f..00bf4619 100644 --- a/api/src/routes/channels/#channel_id/webhooks.ts +++ b/api/src/routes/channels/#channel_id/webhooks.ts @@ -12,7 +12,7 @@ export interface WebhookCreateSchema { * @maxLength 80 */ name: string; - avatar: string; + avatar?: string; } //TODO: implement webhooks router.get("/", route({}), async (req: Request, res: Response) => { @@ -36,6 +36,7 @@ router.post("/", route({ body: "WebhookCreateSchema", permission: "MANAGE_WEBHOO if (name === "clyde") throw new HTTPError("Invalid name", 400); // TODO: save webhook in database and send response + res.json(new Webhook()); }); export default router; diff --git a/api/src/util/handlers/route.ts b/api/src/util/handlers/route.ts index eaf7dc91..f8130f3c 100644 --- a/api/src/util/handlers/route.ts +++ b/api/src/util/handlers/route.ts @@ -117,6 +117,11 @@ export function route(opts: RouteOptions) { const valid = validate(normalizeBody(req.body)); if (!valid) { const fields: Record = {}; + if(process.env.LOG_INVALID_BODY) { + console.log(`Got invalid request: ${req.method} ${req.originalUrl}`) + console.log(req.body) + validate.errors?.forEach(x => console.log(x.params)) + } validate.errors?.forEach((x) => (fields[x.instancePath.slice(1)] = { code: x.keyword, message: x.message || "" })); throw FieldErrors(fields); } diff --git a/bundle/package.json b/bundle/package.json index b67598b8..7431a96f 100644 --- a/bundle/package.json +++ b/bundle/package.json @@ -9,10 +9,11 @@ "depcheck": "node scripts/depcheck.js", "syncdeps": "node scripts/install.js", "build": "node scripts/build.js", + "genschemas": "node scripts/update_schemas.js", "start": "node scripts/build.js && node --enable-source-maps dist/bundle/src/start.js", "start:bundle": "node --enable-source-maps dist/bundle/src/start.js", "start:bundle:dbg": "node --enable-source-maps --inspect dist/bundle/src/start.js", - "start:bundle:vscode-dbg": "npm run build clean logerrors pretty-errors && node --enable-source-maps --inspect dist/bundle/src/start.js", + "start:bundle:vscode-dbg": "npm run genschemas && npm run build clean logerrors pretty-errors && node --enable-source-maps --inspect dist/bundle/src/start.js", "test": "echo \"Error: no test specified\" && exit 1", "migrate": "cd ../util/ && npm i && node --require ts-node/register node_modules/typeorm/cli.js -f ../util/ormconfig.json migration:run", "tsnode": "npx ts-node --transpile-only -P tsnode.tsconfig.json src/start.ts" diff --git a/bundle/scripts/update_schemas.js b/bundle/scripts/update_schemas.js index 516b9592..a018120b 100644 --- a/bundle/scripts/update_schemas.js +++ b/bundle/scripts/update_schemas.js @@ -6,4 +6,4 @@ const { argv, stdout, exit } = require("process"); const { execIn, getLines, parts } = require("./utils"); -execIn("node scripts/generate_schema.js", path.join("..", "..", "api")); \ No newline at end of file +execIn("node scripts/generate_schema.js", path.join("..", "api")); \ No newline at end of file diff --git a/env-vars.md b/env-vars.md index c24ea1a2..6c56c184 100644 --- a/env-vars.md +++ b/env-vars.md @@ -14,4 +14,5 @@ |STORAGE\_BUCKET|s3 bucket name|S3 bucket name| |DB\_UNSAFE|any|Ignores migrations for database, enabled if defined| |DB\_VERBOSE|any|Log database queries, enabled if defined| -|DB\_MIGRATE|any|Exit fosscord after connecting to and migrating database, used internally| \ No newline at end of file +|DB\_MIGRATE|any|Exit fosscord after connecting to and migrating database, used internally| +|LOG\_INVALID\_BODY|any|Log request method, path and body if invalid| diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts index 4e275592..ce4385a3 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts @@ -102,8 +102,9 @@ export async function onIdentify(this: WebSocket, data: Payload) { ]); if (!user) return this.close(CLOSECODES.Authentication_failed); - if (!user.settings) { + if (!user.settings) { //settings may not exist after updating... user.settings = new UserSettings(); + user.settings.id = user.id; await user.settings.save(); } diff --git a/util/src/entities/BaseClass.ts b/util/src/entities/BaseClass.ts index c872e7f1..aecc2465 100644 --- a/util/src/entities/BaseClass.ts +++ b/util/src/entities/BaseClass.ts @@ -1,5 +1,5 @@ import "reflect-metadata"; -import { BaseEntity, EntityMetadata, ObjectIdColumn, PrimaryColumn, FindOptionsWhere, Generated, SaveOptions } from "typeorm"; +import { BaseEntity, ObjectIdColumn, PrimaryColumn, SaveOptions } from "typeorm"; import { Snowflake } from "../util/Snowflake"; export class BaseClassWithoutId extends BaseEntity { diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index ade0fb39..a576d7af 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -151,6 +151,13 @@ export class Channel extends BaseClass { }) webhooks?: Webhook[]; + @Column({ nullable: true }) + flags?: number = 0; + + @Column({ nullable: true }) + default_thread_rate_limit_per_user?: number = 0; + + // TODO: DM channel static async createChannel( channel: Partial, diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts index 6edcda97..61343e81 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts @@ -185,8 +185,10 @@ export class User extends BaseClass { notes: { [key: string]: string } = {}; //key is ID of user async save(): Promise { - await this.settings.save(); - return this.save(); + if(!this.settings) this.settings = new UserSettings(); + this.settings.id = this.id; + //await this.settings.save(); + return super.save(); } toPublicUser() { diff --git a/util/src/migrations/mariadb/1660265930624-CodeCleanup5.ts b/util/src/migrations/mariadb/1660265930624-CodeCleanup5.ts new file mode 100644 index 00000000..04f8e6af --- /dev/null +++ b/util/src/migrations/mariadb/1660265930624-CodeCleanup5.ts @@ -0,0 +1,53 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup51660265930624 implements MigrationInterface { + name = 'CodeCleanup51660265930624' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE \`users\` + ADD \`settingsId\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`users\` + ADD UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` (\`settingsId\`) + `); + await queryRunner.query(` + ALTER TABLE \`channels\` + ADD \`flags\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`channels\` + ADD \`default_thread_rate_limit_per_user\` int NULL + `); + await queryRunner.query(` + CREATE UNIQUE INDEX \`REL_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`) + `); + await queryRunner.query(` + ALTER TABLE \`users\` + ADD CONSTRAINT \`FK_76ba283779c8441fd5ff819c8cf\` FOREIGN KEY (\`settingsId\`) REFERENCES \`user_settings\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE \`users\` DROP FOREIGN KEY \`FK_76ba283779c8441fd5ff819c8cf\` + `); + await queryRunner.query(` + DROP INDEX \`REL_76ba283779c8441fd5ff819c8c\` ON \`users\` + `); + await queryRunner.query(` + ALTER TABLE \`channels\` DROP COLUMN \`default_thread_rate_limit_per_user\` + `); + await queryRunner.query(` + ALTER TABLE \`channels\` DROP COLUMN \`flags\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\` + `); + await queryRunner.query(` + ALTER TABLE \`users\` DROP COLUMN \`settingsId\` + `); + } + +} diff --git a/util/src/migrations/postgres/1660265907544-CodeCleanup5.ts b/util/src/migrations/postgres/1660265907544-CodeCleanup5.ts new file mode 100644 index 00000000..157d686a --- /dev/null +++ b/util/src/migrations/postgres/1660265907544-CodeCleanup5.ts @@ -0,0 +1,26 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CodeCleanup51660265907544 implements MigrationInterface { + name = 'CodeCleanup51660265907544' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE "channels" + ADD "flags" integer + `); + await queryRunner.query(` + ALTER TABLE "channels" + ADD "default_thread_rate_limit_per_user" integer + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE "channels" DROP COLUMN "default_thread_rate_limit_per_user" + `); + await queryRunner.query(` + ALTER TABLE "channels" DROP COLUMN "flags" + `); + } + +} diff --git a/util/src/migrations/sqlite/1660260539853-CodeCleanup4.ts b/util/src/migrations/sqlite/1660260539853-CodeCleanup4.ts deleted file mode 100644 index d3f2a40d..00000000 --- a/util/src/migrations/sqlite/1660260539853-CodeCleanup4.ts +++ /dev/null @@ -1,459 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class CodeCleanup41660260539853 implements MigrationInterface { - name = 'CodeCleanup41660260539853' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - CREATE TABLE "temporary_users" ( - "id" varchar PRIMARY KEY NOT NULL, - "username" varchar NOT NULL, - "discriminator" varchar NOT NULL, - "avatar" varchar, - "accent_color" integer, - "banner" varchar, - "phone" varchar, - "desktop" boolean NOT NULL, - "mobile" boolean NOT NULL, - "premium" boolean NOT NULL, - "premium_type" integer NOT NULL, - "bot" boolean NOT NULL, - "bio" varchar NOT NULL, - "system" boolean NOT NULL, - "nsfw_allowed" boolean NOT NULL, - "mfa_enabled" boolean NOT NULL, - "totp_secret" varchar, - "totp_last_ticket" varchar, - "created_at" datetime NOT NULL, - "premium_since" datetime, - "verified" boolean NOT NULL, - "disabled" boolean NOT NULL, - "deleted" boolean NOT NULL, - "email" varchar, - "flags" varchar NOT NULL, - "public_flags" integer NOT NULL, - "rights" bigint NOT NULL, - "data" text NOT NULL, - "fingerprints" text NOT NULL, - "extended_settings" text NOT NULL, - "notes" text NOT NULL, - "settingsId" varchar, - CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId") - ) - `); - await queryRunner.query(` - INSERT INTO "temporary_users"( - "id", - "username", - "discriminator", - "avatar", - "accent_color", - "banner", - "phone", - "desktop", - "mobile", - "premium", - "premium_type", - "bot", - "bio", - "system", - "nsfw_allowed", - "mfa_enabled", - "totp_secret", - "totp_last_ticket", - "created_at", - "premium_since", - "verified", - "disabled", - "deleted", - "email", - "flags", - "public_flags", - "rights", - "data", - "fingerprints", - "extended_settings", - "notes" - ) - SELECT "id", - "username", - "discriminator", - "avatar", - "accent_color", - "banner", - "phone", - "desktop", - "mobile", - "premium", - "premium_type", - "bot", - "bio", - "system", - "nsfw_allowed", - "mfa_enabled", - "totp_secret", - "totp_last_ticket", - "created_at", - "premium_since", - "verified", - "disabled", - "deleted", - "email", - "flags", - "public_flags", - "rights", - "data", - "fingerprints", - "extended_settings", - "notes" - FROM "users" - `); - await queryRunner.query(` - DROP TABLE "users" - `); - await queryRunner.query(` - ALTER TABLE "temporary_users" - RENAME TO "users" - `); - await queryRunner.query(` - CREATE TABLE "temporary_users" ( - "id" varchar PRIMARY KEY NOT NULL, - "username" varchar NOT NULL, - "discriminator" varchar NOT NULL, - "avatar" varchar, - "accent_color" integer, - "banner" varchar, - "phone" varchar, - "desktop" boolean NOT NULL, - "mobile" boolean NOT NULL, - "premium" boolean NOT NULL, - "premium_type" integer NOT NULL, - "bot" boolean NOT NULL, - "bio" varchar NOT NULL, - "system" boolean NOT NULL, - "nsfw_allowed" boolean NOT NULL, - "mfa_enabled" boolean NOT NULL, - "totp_secret" varchar, - "totp_last_ticket" varchar, - "created_at" datetime NOT NULL, - "premium_since" datetime, - "verified" boolean NOT NULL, - "disabled" boolean NOT NULL, - "deleted" boolean NOT NULL, - "email" varchar, - "flags" varchar NOT NULL, - "public_flags" integer NOT NULL, - "rights" bigint NOT NULL, - "data" text NOT NULL, - "fingerprints" text NOT NULL, - "extended_settings" text NOT NULL, - "notes" text NOT NULL, - "settingsId" varchar, - CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId"), - CONSTRAINT "FK_76ba283779c8441fd5ff819c8cf" FOREIGN KEY ("settingsId") REFERENCES "user_settings" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "temporary_users"( - "id", - "username", - "discriminator", - "avatar", - "accent_color", - "banner", - "phone", - "desktop", - "mobile", - "premium", - "premium_type", - "bot", - "bio", - "system", - "nsfw_allowed", - "mfa_enabled", - "totp_secret", - "totp_last_ticket", - "created_at", - "premium_since", - "verified", - "disabled", - "deleted", - "email", - "flags", - "public_flags", - "rights", - "data", - "fingerprints", - "extended_settings", - "notes", - "settingsId" - ) - SELECT "id", - "username", - "discriminator", - "avatar", - "accent_color", - "banner", - "phone", - "desktop", - "mobile", - "premium", - "premium_type", - "bot", - "bio", - "system", - "nsfw_allowed", - "mfa_enabled", - "totp_secret", - "totp_last_ticket", - "created_at", - "premium_since", - "verified", - "disabled", - "deleted", - "email", - "flags", - "public_flags", - "rights", - "data", - "fingerprints", - "extended_settings", - "notes", - "settingsId" - FROM "users" - `); - await queryRunner.query(` - DROP TABLE "users" - `); - await queryRunner.query(` - ALTER TABLE "temporary_users" - RENAME TO "users" - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE "users" - RENAME TO "temporary_users" - `); - await queryRunner.query(` - CREATE TABLE "users" ( - "id" varchar PRIMARY KEY NOT NULL, - "username" varchar NOT NULL, - "discriminator" varchar NOT NULL, - "avatar" varchar, - "accent_color" integer, - "banner" varchar, - "phone" varchar, - "desktop" boolean NOT NULL, - "mobile" boolean NOT NULL, - "premium" boolean NOT NULL, - "premium_type" integer NOT NULL, - "bot" boolean NOT NULL, - "bio" varchar NOT NULL, - "system" boolean NOT NULL, - "nsfw_allowed" boolean NOT NULL, - "mfa_enabled" boolean NOT NULL, - "totp_secret" varchar, - "totp_last_ticket" varchar, - "created_at" datetime NOT NULL, - "premium_since" datetime, - "verified" boolean NOT NULL, - "disabled" boolean NOT NULL, - "deleted" boolean NOT NULL, - "email" varchar, - "flags" varchar NOT NULL, - "public_flags" integer NOT NULL, - "rights" bigint NOT NULL, - "data" text NOT NULL, - "fingerprints" text NOT NULL, - "extended_settings" text NOT NULL, - "notes" text NOT NULL, - "settingsId" varchar, - CONSTRAINT "UQ_b1dd13b6ed980004a795ca184a6" UNIQUE ("settingsId") - ) - `); - await queryRunner.query(` - INSERT INTO "users"( - "id", - "username", - "discriminator", - "avatar", - "accent_color", - "banner", - "phone", - "desktop", - "mobile", - "premium", - "premium_type", - "bot", - "bio", - "system", - "nsfw_allowed", - "mfa_enabled", - "totp_secret", - "totp_last_ticket", - "created_at", - "premium_since", - "verified", - "disabled", - "deleted", - "email", - "flags", - "public_flags", - "rights", - "data", - "fingerprints", - "extended_settings", - "notes", - "settingsId" - ) - SELECT "id", - "username", - "discriminator", - "avatar", - "accent_color", - "banner", - "phone", - "desktop", - "mobile", - "premium", - "premium_type", - "bot", - "bio", - "system", - "nsfw_allowed", - "mfa_enabled", - "totp_secret", - "totp_last_ticket", - "created_at", - "premium_since", - "verified", - "disabled", - "deleted", - "email", - "flags", - "public_flags", - "rights", - "data", - "fingerprints", - "extended_settings", - "notes", - "settingsId" - FROM "temporary_users" - `); - await queryRunner.query(` - DROP TABLE "temporary_users" - `); - await queryRunner.query(` - ALTER TABLE "users" - RENAME TO "temporary_users" - `); - await queryRunner.query(` - CREATE TABLE "users" ( - "id" varchar PRIMARY KEY NOT NULL, - "username" varchar NOT NULL, - "discriminator" varchar NOT NULL, - "avatar" varchar, - "accent_color" integer, - "banner" varchar, - "phone" varchar, - "desktop" boolean NOT NULL, - "mobile" boolean NOT NULL, - "premium" boolean NOT NULL, - "premium_type" integer NOT NULL, - "bot" boolean NOT NULL, - "bio" varchar NOT NULL, - "system" boolean NOT NULL, - "nsfw_allowed" boolean NOT NULL, - "mfa_enabled" boolean NOT NULL, - "totp_secret" varchar, - "totp_last_ticket" varchar, - "created_at" datetime NOT NULL, - "premium_since" datetime, - "verified" boolean NOT NULL, - "disabled" boolean NOT NULL, - "deleted" boolean NOT NULL, - "email" varchar, - "flags" varchar NOT NULL, - "public_flags" integer NOT NULL, - "rights" bigint NOT NULL, - "data" text NOT NULL, - "fingerprints" text NOT NULL, - "extended_settings" text NOT NULL, - "notes" text NOT NULL - ) - `); - await queryRunner.query(` - INSERT INTO "users"( - "id", - "username", - "discriminator", - "avatar", - "accent_color", - "banner", - "phone", - "desktop", - "mobile", - "premium", - "premium_type", - "bot", - "bio", - "system", - "nsfw_allowed", - "mfa_enabled", - "totp_secret", - "totp_last_ticket", - "created_at", - "premium_since", - "verified", - "disabled", - "deleted", - "email", - "flags", - "public_flags", - "rights", - "data", - "fingerprints", - "extended_settings", - "notes" - ) - SELECT "id", - "username", - "discriminator", - "avatar", - "accent_color", - "banner", - "phone", - "desktop", - "mobile", - "premium", - "premium_type", - "bot", - "bio", - "system", - "nsfw_allowed", - "mfa_enabled", - "totp_secret", - "totp_last_ticket", - "created_at", - "premium_since", - "verified", - "disabled", - "deleted", - "email", - "flags", - "public_flags", - "rights", - "data", - "fingerprints", - "extended_settings", - "notes" - FROM "temporary_users" - `); - await queryRunner.query(` - DROP TABLE "temporary_users" - `); - } - -} -- cgit 1.5.1 From 10bd81274722823f875ba31eaf5fc670bfb22ceb Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Fri, 12 Aug 2022 11:36:39 +0200 Subject: Split schemas into files in util --- api/assets/schemas.json | 2247 ++++++++++++-------- api/src/routes/auth/login.ts | 11 +- api/src/routes/auth/mfa/totp.ts | 9 +- api/src/routes/auth/register.ts | 29 +- api/src/routes/channels/#channel_id/index.ts | 30 +- api/src/routes/channels/#channel_id/invites.ts | 12 - .../#channel_id/messages/#message_id/ack.ts | 9 - .../#channel_id/messages/#message_id/index.ts | 4 +- .../channels/#channel_id/messages/bulk-delete.ts | 4 - .../routes/channels/#channel_id/messages/index.ts | 36 +- api/src/routes/channels/#channel_id/permissions.ts | 7 +- api/src/routes/channels/#channel_id/purge.ts | 7 +- api/src/routes/channels/#channel_id/webhooks.ts | 8 - api/src/routes/guilds/#guild_id/audit-logs.ts | 3 - api/src/routes/guilds/#guild_id/bans.ts | 24 +- api/src/routes/guilds/#guild_id/channels.ts | 3 +- api/src/routes/guilds/#guild_id/emojis.ts | 14 +- api/src/routes/guilds/#guild_id/index.ts | 20 +- api/src/routes/guilds/#guild_id/integrations.ts | 1 - .../guilds/#guild_id/members/#member_id/index.ts | 6 +- .../guilds/#guild_id/members/#member_id/nick.ts | 4 - api/src/routes/guilds/#guild_id/prune.ts | 7 - .../guilds/#guild_id/roles/#role_id/index.ts | 3 +- api/src/routes/guilds/#guild_id/roles/index.ts | 14 +- api/src/routes/guilds/#guild_id/stickers.ts | 17 +- api/src/routes/guilds/#guild_id/templates.ts | 10 - api/src/routes/guilds/#guild_id/vanity-url.ts | 10 +- .../#guild_id/voice-states/#user_id/index.ts | 14 +- api/src/routes/guilds/#guild_id/webhooks.ts | 1 - api/src/routes/guilds/#guild_id/welcome_screen.ts | 13 +- api/src/routes/guilds/#guild_id/widget.ts | 7 +- api/src/routes/guilds/index.ts | 16 +- api/src/routes/guilds/templates/index.ts | 9 +- api/src/routes/users/@me/channels.ts | 7 +- api/src/routes/users/@me/index.ts | 21 +- api/src/routes/users/@me/mfa/codes.ts | 7 +- api/src/routes/users/@me/mfa/totp/disable.ts | 6 +- api/src/routes/users/@me/mfa/totp/enable.ts | 8 +- api/src/routes/users/@me/relationships.ts | 9 - api/src/routes/users/@me/settings.ts | 2 - api/src/util/handlers/Message.ts | 3 +- gateway/src/opcodes/Identify.ts | 2 +- gateway/src/opcodes/LazyRequest.ts | 3 +- gateway/src/opcodes/PresenceUpdate.ts | 3 +- gateway/src/opcodes/VoiceStateUpdate.ts | 2 +- gateway/src/schema/Activity.ts | 51 - gateway/src/schema/Identify.ts | 89 - gateway/src/schema/LazyRequest.ts | 19 - gateway/src/schema/VoiceStateUpdateSchema.ts | 15 - util/src/index.ts | 3 +- util/src/schemas/ActivitySchema.ts | 51 + util/src/schemas/BanCreateSchema.ts | 5 + util/src/schemas/BanModeratorSchema.ts | 8 + util/src/schemas/BanRegistrySchema.ts | 9 + util/src/schemas/BulkDeleteSchema.ts | 4 + util/src/schemas/ChannelModifySchema.ts | 29 + .../schemas/ChannelPermissionOverwriteSchema.ts | 5 + util/src/schemas/DmChannelCreateSchema.ts | 5 + util/src/schemas/EmojiCreateSchema.ts | 7 + util/src/schemas/EmojiModifySchema.ts | 5 + util/src/schemas/GuildCreateSchema.ts | 14 + util/src/schemas/GuildTemplateCreateSchema.ts | 5 + util/src/schemas/GuildUpdateSchema.ts | 18 + util/src/schemas/GuildUpdateWelcomeScreenSchema.ts | 11 + util/src/schemas/IdentifySchema.ts | 89 + util/src/schemas/InviteCreateSchema.ts | 12 + util/src/schemas/LazyRequestSchema.ts | 19 + util/src/schemas/LoginSchema.ts | 9 + util/src/schemas/MemberChangeSchema.ts | 4 + util/src/schemas/MemberNickChangeSchema.ts | 4 + util/src/schemas/MessageAcknowledgeSchema.ts | 8 + util/src/schemas/MessageCreateSchema.ts | 34 + util/src/schemas/MfaCodesSchema.ts | 5 + util/src/schemas/ModifyGuildStickerSchema.ts | 16 + util/src/schemas/PruneSchema.ts | 7 + util/src/schemas/PurgeSchema.ts | 5 + util/src/schemas/RegisterSchema.ts | 27 + util/src/schemas/RelationshipPostSchema.ts | 5 + util/src/schemas/RelationshipPutSchema.ts | 6 + util/src/schemas/RoleModifySchema.ts | 11 + util/src/schemas/TemplateCreateSchema.ts | 5 + util/src/schemas/TemplateModifySchema.ts | 5 + util/src/schemas/TotpDisableSchema.ts | 4 + util/src/schemas/TotpEnableSchema.ts | 6 + util/src/schemas/TotpSchema.ts | 7 + util/src/schemas/UserModifySchema.ts | 19 + util/src/schemas/UserSettingsSchema.ts | 4 + util/src/schemas/VanityUrlSchema.ts | 8 + util/src/schemas/VoiceStateUpdateSchema.ts | 18 + util/src/schemas/WebhookCreateSchema.ts | 8 + util/src/schemas/WidgetModifySchema.ts | 5 + util/src/schemas/index.ts | 41 + util/src/util/Config.ts | 5 +- 93 files changed, 1974 insertions(+), 1457 deletions(-) delete mode 100644 gateway/src/schema/Activity.ts delete mode 100644 gateway/src/schema/Identify.ts delete mode 100644 gateway/src/schema/LazyRequest.ts delete mode 100644 gateway/src/schema/VoiceStateUpdateSchema.ts create mode 100644 util/src/schemas/ActivitySchema.ts create mode 100644 util/src/schemas/BanCreateSchema.ts create mode 100644 util/src/schemas/BanModeratorSchema.ts create mode 100644 util/src/schemas/BanRegistrySchema.ts create mode 100644 util/src/schemas/BulkDeleteSchema.ts create mode 100644 util/src/schemas/ChannelModifySchema.ts create mode 100644 util/src/schemas/ChannelPermissionOverwriteSchema.ts create mode 100644 util/src/schemas/DmChannelCreateSchema.ts create mode 100644 util/src/schemas/EmojiCreateSchema.ts create mode 100644 util/src/schemas/EmojiModifySchema.ts create mode 100644 util/src/schemas/GuildCreateSchema.ts create mode 100644 util/src/schemas/GuildTemplateCreateSchema.ts create mode 100644 util/src/schemas/GuildUpdateSchema.ts create mode 100644 util/src/schemas/GuildUpdateWelcomeScreenSchema.ts create mode 100644 util/src/schemas/IdentifySchema.ts create mode 100644 util/src/schemas/InviteCreateSchema.ts create mode 100644 util/src/schemas/LazyRequestSchema.ts create mode 100644 util/src/schemas/LoginSchema.ts create mode 100644 util/src/schemas/MemberChangeSchema.ts create mode 100644 util/src/schemas/MemberNickChangeSchema.ts create mode 100644 util/src/schemas/MessageAcknowledgeSchema.ts create mode 100644 util/src/schemas/MessageCreateSchema.ts create mode 100644 util/src/schemas/MfaCodesSchema.ts create mode 100644 util/src/schemas/ModifyGuildStickerSchema.ts create mode 100644 util/src/schemas/PruneSchema.ts create mode 100644 util/src/schemas/PurgeSchema.ts create mode 100644 util/src/schemas/RegisterSchema.ts create mode 100644 util/src/schemas/RelationshipPostSchema.ts create mode 100644 util/src/schemas/RelationshipPutSchema.ts create mode 100644 util/src/schemas/RoleModifySchema.ts create mode 100644 util/src/schemas/TemplateCreateSchema.ts create mode 100644 util/src/schemas/TemplateModifySchema.ts create mode 100644 util/src/schemas/TotpDisableSchema.ts create mode 100644 util/src/schemas/TotpEnableSchema.ts create mode 100644 util/src/schemas/TotpSchema.ts create mode 100644 util/src/schemas/UserModifySchema.ts create mode 100644 util/src/schemas/UserSettingsSchema.ts create mode 100644 util/src/schemas/VanityUrlSchema.ts create mode 100644 util/src/schemas/VoiceStateUpdateSchema.ts create mode 100644 util/src/schemas/WebhookCreateSchema.ts create mode 100644 util/src/schemas/WidgetModifySchema.ts create mode 100644 util/src/schemas/index.ts (limited to 'gateway/src/opcodes/Identify.ts') diff --git a/api/assets/schemas.json b/api/assets/schemas.json index d8576514..f102f9d0 100644 --- a/api/assets/schemas.json +++ b/api/assets/schemas.json @@ -98,362 +98,264 @@ ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "MessageCreateSchema": { + "ActivitySchema": { "type": "object", "properties": { - "type": { - "type": "integer" - }, - "content": { - "type": "string" - }, - "nonce": { - "type": "string" - }, - "channel_id": { - "type": "string" - }, - "tts": { + "afk": { "type": "boolean" }, - "flags": { - "type": "string" + "status": { + "$ref": "#/definitions/Status" }, - "embeds": { + "activities": { "type": "array", "items": { - "$ref": "#/definitions/Embed" + "$ref": "#/definitions/Activity" } }, - "embed": { - "$ref": "#/definitions/Embed" - }, - "allowed_mentions": { - "type": "object", - "properties": { - "parse": { - "type": "array", - "items": { - "type": "string" - } - }, - "roles": { - "type": "array", - "items": { - "type": "string" - } - }, - "users": { - "type": "array", - "items": { - "type": "string" - } - }, - "replied_user": { - "type": "boolean" - } - }, - "additionalProperties": false - }, - "message_reference": { - "type": "object", - "properties": { - "message_id": { - "type": "string" - }, - "channel_id": { - "type": "string" - }, - "guild_id": { - "type": "string" - }, - "fail_if_not_exists": { - "type": "boolean" - } - }, - "additionalProperties": false, - "required": [ - "channel_id", - "message_id" - ] - }, - "payload_json": { - "type": "string" - }, - "file": {}, - "attachments": { - "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", - "type": "array", - "items": {} - }, - "sticker_ids": { - "type": "array", - "items": { - "type": "string" - } + "since": { + "type": "integer" } }, "additionalProperties": false, + "required": [ + "afk", + "status" + ], "definitions": { - "Embed": { + "Status": { + "enum": [ + "dnd", + "idle", + "invisible", + "offline", + "online" + ], + "type": "string" + }, + "Activity": { "type": "object", "properties": { - "title": { + "name": { "type": "string" }, "type": { - "enum": [ - "article", - "gifv", - "image", - "link", - "rich", - "video" - ], - "type": "string" - }, - "description": { - "type": "string" + "$ref": "#/definitions/ActivityType" }, "url": { "type": "string" }, - "timestamp": { - "type": "string", - "format": "date-time" - }, - "color": { + "created_at": { "type": "integer" }, - "footer": { + "timestamps": { "type": "object", "properties": { - "text": { - "type": "string" + "start": { + "type": "integer" }, - "icon_url": { - "type": "string" - }, - "proxy_icon_url": { - "type": "string" + "end": { + "type": "integer" } }, "additionalProperties": false, "required": [ - "text" + "end", + "start" ] }, - "image": { - "$ref": "#/definitions/EmbedImage" + "application_id": { + "type": "string" }, - "thumbnail": { - "$ref": "#/definitions/EmbedImage" + "details": { + "type": "string" }, - "video": { - "$ref": "#/definitions/EmbedImage" + "state": { + "type": "string" }, - "provider": { + "emoji": { "type": "object", "properties": { "name": { "type": "string" }, - "url": { + "id": { + "type": "string" + }, + "animated": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "animated", + "name" + ] + }, + "party": { + "type": "object", + "properties": { + "id": { "type": "string" + }, + "size": { + "type": "array", + "items": [ + { + "type": "integer" + } + ], + "minItems": 1, + "maxItems": 1 } }, "additionalProperties": false }, - "author": { + "assets": { "type": "object", "properties": { - "name": { + "large_image": { "type": "string" }, - "url": { + "large_text": { "type": "string" }, - "icon_url": { + "small_image": { "type": "string" }, - "proxy_icon_url": { + "small_text": { "type": "string" } }, "additionalProperties": false }, - "fields": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "value": { - "type": "string" - }, - "inline": { - "type": "boolean" - } + "secrets": { + "type": "object", + "properties": { + "join": { + "type": "string" }, - "additionalProperties": false, - "required": [ - "name", - "value" - ] - } - } - }, - "additionalProperties": false - }, - "EmbedImage": { - "type": "object", - "properties": { - "url": { - "type": "string" - }, - "proxy_url": { - "type": "string" + "spectate": { + "type": "string" + }, + "match": { + "type": "string" + } + }, + "additionalProperties": false }, - "height": { - "type": "integer" + "instance": { + "type": "boolean" }, - "width": { - "type": "integer" + "flags": { + "type": "string" } }, - "additionalProperties": false + "additionalProperties": false, + "required": [ + "flags", + "name", + "type" + ] + }, + "ActivityType": { + "enum": [ + 0, + 1, + 2, + 4, + 5 + ], + "type": "number" } }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "RouteResponse": { + "BanCreateSchema": { "type": "object", "properties": { - "status": { - "type": "integer" - }, - "body": { - "type": "array", - "items": { - "type": "string" - } + "delete_message_days": { + "type": "string" }, - "headers": { - "$ref": "#/definitions/Record" + "reason": { + "type": "string" } }, "additionalProperties": false, - "definitions": { - "Record": { - "type": "object", - "additionalProperties": false - } - }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "LoginSchema": { + "BanModeratorSchema": { "type": "object", "properties": { - "login": { + "id": { "type": "string" }, - "password": { + "user_id": { "type": "string" }, - "undelete": { - "type": "boolean" - }, - "captcha_key": { + "guild_id": { "type": "string" }, - "login_source": { + "executor_id": { "type": "string" }, - "gift_code_sku_id": { + "reason": { "type": "string" } }, "additionalProperties": false, "required": [ - "login", - "password" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "TotpSchema": { - "type": "object", - "properties": { - "code": { - "type": "string" - }, - "ticket": { - "type": "string" - }, - "gift_code_sku_id": { - "type": [ - "null", - "string" - ] - }, - "login_source": { - "type": [ - "null", - "string" - ] - } - }, - "additionalProperties": false, - "required": [ - "code", - "ticket" + "executor_id", + "guild_id", + "id", + "user_id" ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "RegisterSchema": { + "BanRegistrySchema": { "type": "object", "properties": { - "username": { - "minLength": 2, - "maxLength": 32, - "type": "string" - }, - "password": { - "minLength": 1, - "maxLength": 72, - "type": "string" - }, - "consent": { - "type": "boolean" - }, - "email": { - "format": "email", + "id": { "type": "string" }, - "fingerprint": { + "user_id": { "type": "string" }, - "invite": { + "guild_id": { "type": "string" }, - "date_of_birth": { + "executor_id": { "type": "string" }, - "gift_code_sku_id": { + "ip": { "type": "string" }, - "captcha_key": { + "reason": { "type": "string" - }, - "promotional_email_opt_in": { - "type": "boolean" } }, "additionalProperties": false, "required": [ - "consent", - "username" + "executor_id", + "guild_id", + "id", + "user_id" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "BulkDeleteSchema": { + "type": "object", + "properties": { + "messages": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false, + "required": [ + "messages" ], "$schema": "http://json-schema.org/draft-07/schema#" }, @@ -573,69 +475,6 @@ }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "InviteCreateSchema": { - "type": "object", - "properties": { - "target_user_id": { - "type": "string" - }, - "target_type": { - "type": "string" - }, - "validate": { - "type": "string" - }, - "max_age": { - "type": "integer" - }, - "max_uses": { - "type": "integer" - }, - "temporary": { - "type": "boolean" - }, - "unique": { - "type": "boolean" - }, - "target_user": { - "type": "string" - }, - "target_user_type": { - "type": "integer" - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "MessageAcknowledgeSchema": { - "type": "object", - "properties": { - "manual": { - "type": "boolean" - }, - "mention_count": { - "type": "integer" - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "BulkDeleteSchema": { - "type": "object", - "properties": { - "messages": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false, - "required": [ - "messages" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, "ChannelPermissionOverwriteSchema": { "type": "object", "properties": { @@ -671,251 +510,84 @@ }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "PurgeSchema": { + "DmChannelCreateSchema": { "type": "object", "properties": { - "before": { + "name": { "type": "string" }, - "after": { - "type": "string" + "recipients": { + "type": "array", + "items": { + "type": "string" + } } }, "additionalProperties": false, "required": [ - "after", - "before" + "recipients" ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "WebhookCreateSchema": { + "EmojiCreateSchema": { "type": "object", "properties": { "name": { - "maxLength": 80, "type": "string" }, - "avatar": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "name" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "GatewayBotResponse": { - "type": "object", - "properties": { - "url": { + "image": { "type": "string" }, - "shards": { - "type": "integer" - }, - "session_start_limit": { - "type": "object", - "properties": { - "total": { - "type": "integer" - }, - "remaining": { - "type": "integer" - }, - "reset_after": { - "type": "integer" - }, - "max_concurrency": { - "type": "integer" - } - }, - "additionalProperties": false, - "required": [ - "max_concurrency", - "remaining", - "reset_after", - "total" + "require_colons": { + "type": [ + "null", + "boolean" ] + }, + "roles": { + "type": "array", + "items": { + "type": "string" + } } }, "additionalProperties": false, "required": [ - "session_start_limit", - "shards", - "url" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "GatewayResponse": { - "type": "object", - "properties": { - "url": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "url" + "image" ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "BanCreateSchema": { + "EmojiModifySchema": { "type": "object", "properties": { - "delete_message_days": { + "name": { "type": "string" }, - "reason": { - "type": "string" + "roles": { + "type": "array", + "items": { + "type": "string" + } } }, "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" }, - "BanRegistrySchema": { + "GuildCreateSchema": { "type": "object", "properties": { - "id": { + "name": { + "maxLength": 100, "type": "string" }, - "user_id": { + "region": { "type": "string" }, - "guild_id": { - "type": "string" - }, - "executor_id": { - "type": "string" - }, - "ip": { - "type": "string" - }, - "reason": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "executor_id", - "guild_id", - "id", - "user_id" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "BanModeratorSchema": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "user_id": { - "type": "string" - }, - "guild_id": { - "type": "string" - }, - "executor_id": { - "type": "string" - }, - "reason": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "executor_id", - "guild_id", - "id", - "user_id" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "ChannelReorderSchema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "position": { - "type": "integer" - }, - "lock_permissions": { - "type": "boolean" - }, - "parent_id": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "id" - ] - }, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "EmojiCreateSchema": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "image": { - "type": "string" - }, - "require_colons": { - "type": [ - "null", - "boolean" - ] - }, - "roles": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false, - "required": [ - "image" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "EmojiModifySchema": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "roles": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "GuildCreateSchema": { - "type": "object", - "properties": { - "name": { - "maxLength": 100, - "type": "string" - }, - "region": { - "type": "string" - }, - "icon": { - "type": [ - "null", - "string" - ] + "icon": { + "type": [ + "null", + "string" + ] }, "channels": { "type": "array", @@ -1054,6 +726,25 @@ }, "$schema": "http://json-schema.org/draft-07/schema#" }, + "GuildTemplateCreateSchema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "avatar": { + "type": [ + "null", + "string" + ] + } + }, + "additionalProperties": false, + "required": [ + "name" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, "GuildUpdateSchema": { "type": "object", "properties": { @@ -1130,470 +821,892 @@ "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" }, - "MemberChangeSchema": { + "GuildUpdateWelcomeScreenSchema": { "type": "object", "properties": { - "roles": { + "welcome_channels": { "type": "array", "items": { - "type": "string" + "type": "object", + "properties": { + "channel_id": { + "type": "string" + }, + "description": { + "type": "string" + }, + "emoji_id": { + "type": "string" + }, + "emoji_name": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "channel_id", + "description", + "emoji_name" + ] } - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "MemberNickChangeSchema": { - "type": "object", - "properties": { - "nick": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "nick" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "PruneSchema": { - "type": "object", - "properties": { - "days": { - "type": "integer" - } - }, - "additionalProperties": false, - "required": [ - "days" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "RoleModifySchema": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "permissions": { - "type": "string" - }, - "color": { - "type": "integer" - }, - "hoist": { - "type": "boolean" }, - "mentionable": { + "enabled": { "type": "boolean" }, - "position": { - "type": "integer" - }, - "icon": { - "type": "string" - }, - "unicode_emoji": { + "description": { "type": "string" } }, "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" }, - "RolePositionUpdateSchema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "position": { - "type": "integer" - } - }, - "additionalProperties": false, - "required": [ - "id", - "position" - ] - }, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "ModifyGuildStickerSchema": { + "IdentifySchema": { "type": "object", "properties": { - "name": { - "minLength": 2, - "maxLength": 30, + "token": { "type": "string" }, - "description": { - "maxLength": 100, - "type": "string" + "properties": { + "type": "object", + "properties": { + "os": { + "type": "string" + }, + "os_atch": { + "type": "string" + }, + "browser": { + "type": "string" + }, + "device": { + "type": "string" + }, + "$os": { + "type": "string" + }, + "$browser": { + "type": "string" + }, + "$device": { + "type": "string" + }, + "browser_user_agent": { + "type": "string" + }, + "browser_version": { + "type": "string" + }, + "os_version": { + "type": "string" + }, + "referrer": { + "type": "string" + }, + "referring_domain": { + "type": "string" + }, + "referrer_current": { + "type": "string" + }, + "referring_domain_current": { + "type": "string" + }, + "release_channel": { + "enum": [ + "canary", + "dev", + "ptb", + "stable" + ], + "type": "string" + }, + "client_build_number": { + "type": "integer" + }, + "client_event_source": {}, + "client_version": { + "type": "string" + }, + "system_locale": { + "type": "string" + } + }, + "additionalProperties": false }, - "tags": { - "maxLength": 200, - "type": "string" + "intents": { + "type": "bigint" + }, + "presence": { + "$ref": "#/definitions/ActivitySchema" + }, + "compress": { + "type": "boolean" + }, + "large_threshold": { + "type": "integer" + }, + "shard": { + "type": "array", + "items": [ + { + "type": "bigint" + }, + { + "type": "bigint" + } + ], + "minItems": 2, + "maxItems": 2 + }, + "guild_subscriptions": { + "type": "boolean" + }, + "capabilities": { + "type": "integer" + }, + "client_state": { + "type": "object", + "properties": { + "guild_hashes": {}, + "highest_last_message_id": { + "type": "string" + }, + "read_state_version": { + "type": "integer" + }, + "user_guild_settings_version": { + "type": "integer" + }, + "user_settings_version": { + "type": "integer" + } + }, + "additionalProperties": false + }, + "v": { + "type": "integer" } }, "additionalProperties": false, "required": [ - "name", - "tags" + "properties", + "token" ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "TemplateCreateSchema": { - "type": "object", - "properties": { - "name": { - "type": "string" + "definitions": { + "ActivitySchema": { + "type": "object", + "properties": { + "afk": { + "type": "boolean" + }, + "status": { + "$ref": "#/definitions/Status" + }, + "activities": { + "type": "array", + "items": { + "$ref": "#/definitions/Activity" + } + }, + "since": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "afk", + "status" + ] }, - "description": { + "Status": { + "enum": [ + "dnd", + "idle", + "invisible", + "offline", + "online" + ], "type": "string" + }, + "Activity": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/ActivityType" + }, + "url": { + "type": "string" + }, + "created_at": { + "type": "integer" + }, + "timestamps": { + "type": "object", + "properties": { + "start": { + "type": "integer" + }, + "end": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "end", + "start" + ] + }, + "application_id": { + "type": "string" + }, + "details": { + "type": "string" + }, + "state": { + "type": "string" + }, + "emoji": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "id": { + "type": "string" + }, + "animated": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "animated", + "name" + ] + }, + "party": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "size": { + "type": "array", + "items": [ + { + "type": "integer" + } + ], + "minItems": 1, + "maxItems": 1 + } + }, + "additionalProperties": false + }, + "assets": { + "type": "object", + "properties": { + "large_image": { + "type": "string" + }, + "large_text": { + "type": "string" + }, + "small_image": { + "type": "string" + }, + "small_text": { + "type": "string" + } + }, + "additionalProperties": false + }, + "secrets": { + "type": "object", + "properties": { + "join": { + "type": "string" + }, + "spectate": { + "type": "string" + }, + "match": { + "type": "string" + } + }, + "additionalProperties": false + }, + "instance": { + "type": "boolean" + }, + "flags": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "flags", + "name", + "type" + ] + }, + "ActivityType": { + "enum": [ + 0, + 1, + 2, + 4, + 5 + ], + "type": "number" } }, - "additionalProperties": false, - "required": [ - "name" - ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "TemplateModifySchema": { + "InviteCreateSchema": { "type": "object", "properties": { - "name": { + "target_user_id": { "type": "string" }, - "description": { + "target_type": { "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "name" - ], - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "VanityUrlSchema": { - "type": "object", - "properties": { - "code": { - "minLength": 1, - "maxLength": 20, + }, + "validate": { + "type": "string" + }, + "max_age": { + "type": "integer" + }, + "max_uses": { + "type": "integer" + }, + "temporary": { + "type": "boolean" + }, + "unique": { + "type": "boolean" + }, + "target_user": { "type": "string" + }, + "target_user_type": { + "type": "integer" } }, "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" }, - "VoiceStateUpdateSchema": { + "LoginSchema": { "type": "object", "properties": { - "channel_id": { + "login": { "type": "string" }, - "guild_id": { + "password": { "type": "string" }, - "suppress": { + "undelete": { "type": "boolean" }, - "request_to_speak_timestamp": { - "type": "string", - "format": "date-time" - }, - "self_mute": { - "type": "boolean" + "captcha_key": { + "type": "string" }, - "self_deaf": { - "type": "boolean" + "login_source": { + "type": "string" }, - "self_video": { - "type": "boolean" + "gift_code_sku_id": { + "type": "string" } }, "additionalProperties": false, "required": [ - "channel_id" + "login", + "password" ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "GuildUpdateWelcomeScreenSchema": { + "MemberChangeSchema": { "type": "object", "properties": { - "welcome_channels": { + "roles": { "type": "array", - "items": { - "type": "object", - "properties": { - "channel_id": { - "type": "string" - }, - "description": { - "type": "string" - }, - "emoji_id": { - "type": "string" - }, - "emoji_name": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "channel_id", - "description", - "emoji_name" - ] + "items": { + "type": "string" } - }, - "enabled": { - "type": "boolean" - }, - "description": { - "type": "string" } }, "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" }, - "WidgetModifySchema": { + "MemberNickChangeSchema": { "type": "object", "properties": { - "enabled": { - "type": "boolean" - }, - "channel_id": { + "nick": { "type": "string" } }, "additionalProperties": false, "required": [ - "channel_id", - "enabled" + "nick" ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "GuildTemplateCreateSchema": { + "MessageAcknowledgeSchema": { "type": "object", "properties": { - "name": { - "type": "string" + "manual": { + "type": "boolean" }, - "avatar": { - "type": [ - "null", - "string" - ] + "mention_count": { + "type": "integer" } }, "additionalProperties": false, - "required": [ - "name" - ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "UserProfileResponse": { + "MessageCreateSchema": { "type": "object", "properties": { - "user": { - "$ref": "#/definitions/UserPublic" + "type": { + "type": "integer" }, - "connected_accounts": { - "$ref": "#/definitions/PublicConnectedAccount" + "content": { + "type": "string" }, - "premium_guild_since": { - "type": "string", - "format": "date-time" + "nonce": { + "type": "string" }, - "premium_since": { - "type": "string", - "format": "date-time" + "channel_id": { + "type": "string" + }, + "tts": { + "type": "boolean" + }, + "flags": { + "type": "string" + }, + "embeds": { + "type": "array", + "items": { + "$ref": "#/definitions/Embed" + } + }, + "embed": { + "$ref": "#/definitions/Embed" + }, + "allowed_mentions": { + "type": "object", + "properties": { + "parse": { + "type": "array", + "items": { + "type": "string" + } + }, + "roles": { + "type": "array", + "items": { + "type": "string" + } + }, + "users": { + "type": "array", + "items": { + "type": "string" + } + }, + "replied_user": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "message_reference": { + "type": "object", + "properties": { + "message_id": { + "type": "string" + }, + "channel_id": { + "type": "string" + }, + "guild_id": { + "type": "string" + }, + "fail_if_not_exists": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "channel_id", + "message_id" + ] + }, + "payload_json": { + "type": "string" + }, + "file": {}, + "attachments": { + "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", + "type": "array", + "items": {} + }, + "sticker_ids": { + "type": "array", + "items": { + "type": "string" + } } }, "additionalProperties": false, - "required": [ - "connected_accounts", - "user" - ], "definitions": { - "UserPublic": { + "Embed": { "type": "object", "properties": { - "username": { + "title": { "type": "string" }, - "discriminator": { + "type": { + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], "type": "string" }, - "id": { + "description": { "type": "string" }, - "public_flags": { - "type": "integer" - }, - "avatar": { + "url": { "type": "string" }, - "accent_color": { + "timestamp": { + "type": "string", + "format": "date-time" + }, + "color": { "type": "integer" }, - "banner": { - "type": "string" + "footer": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "text" + ] }, - "bio": { - "type": "string" + "image": { + "$ref": "#/definitions/EmbedImage" }, - "bot": { - "type": "boolean" + "thumbnail": { + "$ref": "#/definitions/EmbedImage" }, - "premium_since": { - "type": "string", - "format": "date-time" - } - }, - "additionalProperties": false, - "required": [ - "bio", - "bot", - "discriminator", - "id", - "premium_since", - "public_flags", - "username" - ] + "video": { + "$ref": "#/definitions/EmbedImage" + }, + "provider": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "author": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "inline": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "name", + "value" + ] + } + } + }, + "additionalProperties": false }, - "PublicConnectedAccount": { + "EmbedImage": { "type": "object", "properties": { - "name": { + "url": { "type": "string" }, - "type": { + "proxy_url": { "type": "string" }, - "verified": { - "type": "boolean" + "height": { + "type": "integer" + }, + "width": { + "type": "integer" } }, - "additionalProperties": false, - "required": [ - "name", - "type", - "verified" - ] + "additionalProperties": false } }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "UserRelationsResponse": { + "MfaCodesSchema": { "type": "object", "properties": { - "object": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "username": { - "type": "string" - }, - "avatar": { - "type": "string" - }, - "discriminator": { - "type": "string" - }, - "public_flags": { - "type": "integer" - } - }, - "additionalProperties": false + "password": { + "type": "string" + }, + "regenerate": { + "type": "boolean" } }, "additionalProperties": false, "required": [ - "object" + "password" ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "DmChannelCreateSchema": { + "ModifyGuildStickerSchema": { "type": "object", "properties": { "name": { + "minLength": 2, + "maxLength": 30, "type": "string" }, - "recipients": { - "type": "array", - "items": { - "type": "string" - } + "description": { + "maxLength": 100, + "type": "string" + }, + "tags": { + "maxLength": 200, + "type": "string" } }, "additionalProperties": false, "required": [ - "recipients" + "name", + "tags" ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "UserModifySchema": { + "PruneSchema": { + "type": "object", + "properties": { + "days": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "days" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "PurgeSchema": { + "type": "object", + "properties": { + "before": { + "type": "string" + }, + "after": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "after", + "before" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "RegisterSchema": { "type": "object", "properties": { "username": { + "minLength": 2, + "maxLength": 32, + "type": "string" + }, + "password": { "minLength": 1, - "maxLength": 100, + "maxLength": 72, + "type": "string" + }, + "consent": { + "type": "boolean" + }, + "email": { + "format": "email", + "type": "string" + }, + "fingerprint": { + "type": "string" + }, + "invite": { + "type": "string" + }, + "date_of_birth": { + "type": "string" + }, + "gift_code_sku_id": { + "type": "string" + }, + "captcha_key": { "type": "string" }, + "promotional_email_opt_in": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "consent", + "username" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "RelationshipPostSchema": { + "type": "object", + "properties": { "discriminator": { "type": "string" }, - "avatar": { - "type": [ - "null", - "string" - ] + "username": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "discriminator", + "username" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "RelationshipPutSchema": { + "type": "object", + "properties": { + "type": { + "enum": [ + 1, + 2, + 3, + 4 + ], + "type": "number" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "RoleModifySchema": { + "type": "object", + "properties": { + "name": { + "type": "string" }, - "bio": { - "maxLength": 1024, + "permissions": { "type": "string" }, - "accent_color": { + "color": { "type": "integer" }, - "banner": { - "type": [ - "null", - "string" - ] + "hoist": { + "type": "boolean" }, - "password": { + "mentionable": { + "type": "boolean" + }, + "position": { + "type": "integer" + }, + "icon": { "type": "string" }, - "new_password": { + "unicode_emoji": { + "type": "string" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "TemplateCreateSchema": { + "type": "object", + "properties": { + "name": { "type": "string" }, - "code": { + "description": { "type": "string" } }, "additionalProperties": false, + "required": [ + "name" + ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "MfaCodesSchema": { + "TemplateModifySchema": { "type": "object", "properties": { - "password": { + "name": { "type": "string" }, - "regenerate": { - "type": "boolean" + "description": { + "type": "string" } }, "additionalProperties": false, "required": [ - "password" + "name" ], "$schema": "http://json-schema.org/draft-07/schema#" }, @@ -1619,47 +1732,86 @@ "code": { "type": "string" }, - "secret": { - "type": "string" + "secret": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "password" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "TotpSchema": { + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "ticket": { + "type": "string" + }, + "gift_code_sku_id": { + "type": [ + "null", + "string" + ] + }, + "login_source": { + "type": [ + "null", + "string" + ] } }, "additionalProperties": false, "required": [ - "password" + "code", + "ticket" ], "$schema": "http://json-schema.org/draft-07/schema#" }, - "RelationshipPutSchema": { - "type": "object", - "properties": { - "type": { - "enum": [ - 1, - 2, - 3, - 4 - ], - "type": "number" - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "RelationshipPostSchema": { + "UserModifySchema": { "type": "object", "properties": { + "username": { + "minLength": 1, + "maxLength": 100, + "type": "string" + }, "discriminator": { "type": "string" }, - "username": { + "avatar": { + "type": [ + "null", + "string" + ] + }, + "bio": { + "maxLength": 1024, + "type": "string" + }, + "accent_color": { + "type": "integer" + }, + "banner": { + "type": [ + "null", + "string" + ] + }, + "password": { + "type": "string" + }, + "new_password": { + "type": "string" + }, + "code": { "type": "string" } }, "additionalProperties": false, - "required": [ - "discriminator", - "username" - ], "$schema": "http://json-schema.org/draft-07/schema#" }, "UserSettingsSchema": { @@ -1775,110 +1927,437 @@ ], "type": "string" }, - "stream_notifications_enabled": { - "type": "boolean" + "stream_notifications_enabled": { + "type": "boolean" + }, + "theme": { + "enum": [ + "dark", + "white" + ], + "type": "string" + }, + "timezone_offset": { + "type": "integer" + }, + "hasId": { + "description": "Checks if entity has an id.\nIf entity composite compose ids, it will check them all.", + "type": "object", + "additionalProperties": false + }, + "save": { + "description": "Saves current entity in the database.\nIf entity does not exist in the database then inserts, otherwise updates.", + "type": "object", + "additionalProperties": false + }, + "remove": { + "description": "Removes current entity from the database.", + "type": "object", + "additionalProperties": false + }, + "softRemove": { + "description": "Records the delete date of current entity.", + "type": "object", + "additionalProperties": false + }, + "recover": { + "description": "Recovers a given entity in the database.", + "type": "object", + "additionalProperties": false + }, + "reload": { + "description": "Reloads entity data from the database.", + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false, + "definitions": { + "CustomStatus": { + "type": "object", + "properties": { + "emoji_id": { + "type": "string" + }, + "emoji_name": { + "type": "string" + }, + "expires_at": { + "type": "integer" + }, + "text": { + "type": "string" + } + }, + "additionalProperties": false + }, + "FriendSourceFlags": { + "type": "object", + "properties": { + "all": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "all" + ] + }, + "GuildFolder": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "guild_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "color", + "guild_ids", + "id", + "name" + ] + } + }, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "VanityUrlSchema": { + "type": "object", + "properties": { + "code": { + "minLength": 1, + "maxLength": 20, + "type": "string" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "VoiceStateUpdateSchema": { + "type": "object", + "properties": { + "channel_id": { + "type": "string" + }, + "guild_id": { + "type": "string" + }, + "suppress": { + "type": "boolean" + }, + "request_to_speak_timestamp": { + "type": "string", + "format": "date-time" + }, + "self_mute": { + "type": "boolean" + }, + "self_deaf": { + "type": "boolean" + }, + "self_video": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "channel_id" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "WebhookCreateSchema": { + "type": "object", + "properties": { + "name": { + "maxLength": 80, + "type": "string" + }, + "avatar": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "name" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "WidgetModifySchema": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "channel_id": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "channel_id", + "enabled" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "RouteResponse": { + "type": "object", + "properties": { + "status": { + "type": "integer" + }, + "body": { + "type": "array", + "items": { + "type": "string" + } }, - "theme": { - "enum": [ - "dark", - "white" - ], + "headers": { + "$ref": "#/definitions/Record" + } + }, + "additionalProperties": false, + "definitions": { + "Record": { + "type": "object", + "additionalProperties": false + } + }, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "GatewayBotResponse": { + "type": "object", + "properties": { + "url": { "type": "string" }, - "timezone_offset": { + "shards": { "type": "integer" }, - "hasId": { - "description": "Checks if entity has an id.\nIf entity composite compose ids, it will check them all.", + "session_start_limit": { "type": "object", - "additionalProperties": false + "properties": { + "total": { + "type": "integer" + }, + "remaining": { + "type": "integer" + }, + "reset_after": { + "type": "integer" + }, + "max_concurrency": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "max_concurrency", + "remaining", + "reset_after", + "total" + ] + } + }, + "additionalProperties": false, + "required": [ + "session_start_limit", + "shards", + "url" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "GatewayResponse": { + "type": "object", + "properties": { + "url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "url" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "ChannelReorderSchema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "position": { + "type": "integer" + }, + "lock_permissions": { + "type": "boolean" + }, + "parent_id": { + "type": "string" + } }, - "save": { - "description": "Saves current entity in the database.\nIf entity does not exist in the database then inserts, otherwise updates.", - "type": "object", - "additionalProperties": false + "additionalProperties": false, + "required": [ + "id" + ] + }, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "RolePositionUpdateSchema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "position": { + "type": "integer" + } }, - "remove": { - "description": "Removes current entity from the database.", - "type": "object", - "additionalProperties": false + "additionalProperties": false, + "required": [ + "id", + "position" + ] + }, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "UserProfileResponse": { + "type": "object", + "properties": { + "user": { + "$ref": "#/definitions/UserPublic" }, - "softRemove": { - "description": "Records the delete date of current entity.", - "type": "object", - "additionalProperties": false + "connected_accounts": { + "$ref": "#/definitions/PublicConnectedAccount" }, - "recover": { - "description": "Recovers a given entity in the database.", - "type": "object", - "additionalProperties": false + "premium_guild_since": { + "type": "string", + "format": "date-time" }, - "reload": { - "description": "Reloads entity data from the database.", - "type": "object", - "additionalProperties": false + "premium_since": { + "type": "string", + "format": "date-time" } }, "additionalProperties": false, + "required": [ + "connected_accounts", + "user" + ], "definitions": { - "CustomStatus": { + "UserPublic": { "type": "object", "properties": { - "emoji_id": { + "username": { "type": "string" }, - "emoji_name": { + "discriminator": { "type": "string" }, - "expires_at": { + "id": { + "type": "string" + }, + "public_flags": { "type": "integer" }, - "text": { + "avatar": { + "type": "string" + }, + "accent_color": { + "type": "integer" + }, + "banner": { + "type": "string" + }, + "bio": { "type": "string" + }, + "bot": { + "type": "boolean" + }, + "premium_since": { + "type": "string", + "format": "date-time" } }, - "additionalProperties": false + "additionalProperties": false, + "required": [ + "bio", + "bot", + "discriminator", + "id", + "premium_since", + "public_flags", + "username" + ] }, - "FriendSourceFlags": { + "PublicConnectedAccount": { "type": "object", "properties": { - "all": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "verified": { "type": "boolean" } }, "additionalProperties": false, "required": [ - "all" + "name", + "type", + "verified" ] - }, - "GuildFolder": { + } + }, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "UserRelationsResponse": { + "type": "object", + "properties": { + "object": { "type": "object", "properties": { - "color": { - "type": "integer" + "id": { + "type": "string" }, - "guild_ids": { - "type": "array", - "items": { - "type": "string" - } + "username": { + "type": "string" }, - "id": { - "type": "integer" + "avatar": { + "type": "string" }, - "name": { + "discriminator": { "type": "string" + }, + "public_flags": { + "type": "integer" } }, - "additionalProperties": false, - "required": [ - "color", - "guild_ids", - "id", - "name" - ] + "additionalProperties": false } }, + "additionalProperties": false, + "required": [ + "object" + ], "$schema": "http://json-schema.org/draft-07/schema#" } } \ No newline at end of file diff --git a/api/src/routes/auth/login.ts b/api/src/routes/auth/login.ts index daef6056..9fc5924d 100644 --- a/api/src/routes/auth/login.ts +++ b/api/src/routes/auth/login.ts @@ -1,21 +1,12 @@ import { Request, Response, Router } from "express"; import { route } from "@fosscord/api"; import bcrypt from "bcrypt"; -import { Config, User, generateToken, adjustEmail, FieldErrors } from "@fosscord/util"; +import { Config, User, generateToken, adjustEmail, FieldErrors, LoginSchema } from "@fosscord/util"; import crypto from "crypto"; const router: Router = Router(); export default router; -export interface LoginSchema { - login: string; - password: string; - undelete?: boolean; - captcha_key?: string; - login_source?: string; - gift_code_sku_id?: string; -} - router.post("/", route({ body: "LoginSchema" }), async (req: Request, res: Response) => { const { login, password, captcha_key, undelete } = req.body as LoginSchema; const email = adjustEmail(login); diff --git a/api/src/routes/auth/mfa/totp.ts b/api/src/routes/auth/mfa/totp.ts index 255cf889..421dbafa 100644 --- a/api/src/routes/auth/mfa/totp.ts +++ b/api/src/routes/auth/mfa/totp.ts @@ -1,17 +1,10 @@ import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; -import { BackupCode, FieldErrors, generateToken, User } from "@fosscord/util"; +import { BackupCode, FieldErrors, generateToken, TotpSchema, User } from "@fosscord/util"; import { verifyToken } from "node-2fa"; import { HTTPError } from "lambert-server"; const router = Router(); -export interface TotpSchema { - code: string, - ticket: string, - gift_code_sku_id?: string | null, - login_source?: string | null, -} - router.post("/", route({ body: "TotpSchema" }), async (req: Request, res: Response) => { const { code, ticket, gift_code_sku_id, login_source } = req.body as TotpSchema; diff --git a/api/src/routes/auth/register.ts b/api/src/routes/auth/register.ts index 5a3d27e9..09366a12 100644 --- a/api/src/routes/auth/register.ts +++ b/api/src/routes/auth/register.ts @@ -1,38 +1,11 @@ import { Request, Response, Router } from "express"; -import { Config, generateToken, Invite, FieldErrors, User, adjustEmail, trimSpecial } from "@fosscord/util"; +import { Config, generateToken, Invite, FieldErrors, User, adjustEmail, trimSpecial, RegisterSchema } from "@fosscord/util"; import { route, getIpAdress, IPAnalysis, isProxy } from "@fosscord/api"; import bcrypt from "bcrypt"; import { HTTPError } from "@fosscord/util"; const router: Router = Router(); -export interface RegisterSchema { - /** - * @minLength 2 - * @maxLength 32 - */ - username: string; - /** - * @minLength 1 - * @maxLength 72 - */ - password?: string; - consent: boolean; - /** - * @TJS-format email - */ - email?: string; - fingerprint?: string; - invite?: string; - /** - * @TJS-type string - */ - date_of_birth?: Date; // "2000-04-03" - gift_code_sku_id?: string; - captcha_key?: string; - promotional_email_opt_in?: boolean; -} - router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Response) => { const body = req.body as RegisterSchema; const { register, security } = Config.get(); diff --git a/api/src/routes/channels/#channel_id/index.ts b/api/src/routes/channels/#channel_id/index.ts index 70c34f05..bb8b868b 100644 --- a/api/src/routes/channels/#channel_id/index.ts +++ b/api/src/routes/channels/#channel_id/index.ts @@ -6,7 +6,8 @@ import { ChannelUpdateEvent, emitEvent, Recipient, - handleFile + handleFile, + ChannelModifySchema } from "@fosscord/util"; import { Request, Response, Router } from "express"; import { route } from "@fosscord/api"; @@ -48,33 +49,6 @@ router.delete("/", route({ permission: "MANAGE_CHANNELS" }), async (req: Request res.send(channel); }); -export interface ChannelModifySchema { - /** - * @maxLength 100 - */ - name?: string; - type?: ChannelType; - topic?: string; - icon?: string | null; - bitrate?: number; - user_limit?: number; - rate_limit_per_user?: number; - position?: number; - permission_overwrites?: { - id: string; - type: ChannelPermissionOverwriteType; - allow: string; - deny: string; - }[]; - parent_id?: string; - id?: string; // is not used (only for guild create) - nsfw?: boolean; - rtc_region?: string; - default_auto_archive_duration?: number; - flags?: number; - default_thread_rate_limit_per_user?: number; -} - router.patch("/", route({ body: "ChannelModifySchema", permission: "MANAGE_CHANNELS" }), async (req: Request, res: Response) => { let payload = req.body as ChannelModifySchema; const { channel_id } = req.params; diff --git a/api/src/routes/channels/#channel_id/invites.ts b/api/src/routes/channels/#channel_id/invites.ts index f111cf54..b5c65c0d 100644 --- a/api/src/routes/channels/#channel_id/invites.ts +++ b/api/src/routes/channels/#channel_id/invites.ts @@ -8,18 +8,6 @@ import { OrmUtils } from "@fosscord/util"; const router: Router = Router(); -export interface InviteCreateSchema { - target_user_id?: string; - target_type?: string; - validate?: string; // ? what is this - max_age?: number; - max_uses?: number; - temporary?: boolean; - unique?: boolean; - target_user?: string; - target_user_type?: number; -} - router.post("/", route({ body: "InviteCreateSchema", permission: "CREATE_INSTANT_INVITE", right: "CREATE_INVITES" }), async (req: Request, res: Response) => { const { user_id } = req; diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts b/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts index c1b8d20f..041f4d5e 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts +++ b/api/src/routes/channels/#channel_id/messages/#message_id/ack.ts @@ -5,15 +5,6 @@ import { OrmUtils } from "@fosscord/util"; const router = Router(); -// TODO: public read receipts & privacy scoping -// TODO: send read state event to all channel members -// TODO: advance-only notification cursor - -export interface MessageAcknowledgeSchema { - manual?: boolean; - mention_count?: number; -} - router.post("/", route({ body: "MessageAcknowledgeSchema" }), async (req: Request, res: Response) => { const { channel_id, message_id } = req.params; diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts index b3b310d3..d7e27062 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts +++ b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts @@ -12,13 +12,13 @@ import { MessageDeleteEvent, MessageUpdateEvent, Snowflake, - uploadFile + uploadFile, + MessageCreateSchema } from "@fosscord/util"; import { Router, Response, Request } from "express"; import multer from "multer"; import { route } from "@fosscord/api"; import { handleMessage, postHandleMessage } from "@fosscord/api"; -import { MessageCreateSchema } from "../index"; import { HTTPError } from "@fosscord/util"; const router = Router(); diff --git a/api/src/routes/channels/#channel_id/messages/bulk-delete.ts b/api/src/routes/channels/#channel_id/messages/bulk-delete.ts index 2e40f110..24a33d2d 100644 --- a/api/src/routes/channels/#channel_id/messages/bulk-delete.ts +++ b/api/src/routes/channels/#channel_id/messages/bulk-delete.ts @@ -8,10 +8,6 @@ const router: Router = Router(); export default router; -export interface BulkDeleteSchema { - messages: string[]; -} - // should users be able to bulk delete messages or only bots? ANSWER: all users // should this request fail, if you provide messages older than 14 days/invalid ids? ANSWER: NO // https://discord.com/developers/docs/resources/channel#bulk-delete-messages diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/api/src/routes/channels/#channel_id/messages/index.ts index c2057422..9ab0d97d 100644 --- a/api/src/routes/channels/#channel_id/messages/index.ts +++ b/api/src/routes/channels/#channel_id/messages/index.ts @@ -5,7 +5,6 @@ import { ChannelType, Config, DmChannelDTO, - Embed, emitEvent, getPermission, getRights, @@ -13,7 +12,8 @@ import { MessageCreateEvent, Snowflake, uploadFile, - Member + Member, + MessageCreateSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { handleMessage, postHandleMessage, route } from "@fosscord/api"; @@ -49,38 +49,6 @@ export function isTextChannel(type: ChannelType): boolean { } } -export interface MessageCreateSchema { - type?: number; - content?: string; - nonce?: string; - channel_id?: string; - tts?: boolean; - flags?: string; - embeds?: Embed[]; - embed?: Embed; - // TODO: ^ embed is deprecated in favor of embeds (https://discord.com/developers/docs/resources/channel#message-object) - allowed_mentions?: { - parse?: string[]; - roles?: string[]; - users?: string[]; - replied_user?: boolean; - }; - message_reference?: { - message_id: string; - channel_id: string; - guild_id?: string; - fail_if_not_exists?: boolean; - }; - payload_json?: string; - file?: any; - /** - TODO: we should create an interface for attachments - TODO: OpenWAAO<-->attachment-style metadata conversion - **/ - attachments?: any[]; - sticker_ids?: string[]; -} - // https://discord.com/developers/docs/resources/channel#create-message // get messages router.get("/", async (req: Request, res: Response) => { diff --git a/api/src/routes/channels/#channel_id/permissions.ts b/api/src/routes/channels/#channel_id/permissions.ts index 06a124bb..34052fe5 100644 --- a/api/src/routes/channels/#channel_id/permissions.ts +++ b/api/src/routes/channels/#channel_id/permissions.ts @@ -1,6 +1,7 @@ import { Channel, ChannelPermissionOverwrite, + ChannelPermissionOverwriteSchema, ChannelPermissionOverwriteType, ChannelUpdateEvent, emitEvent, @@ -10,13 +11,9 @@ import { } from "@fosscord/util"; import { Router, Response, Request } from "express"; import { HTTPError } from "@fosscord/util"; - import { route } from "@fosscord/api"; -const router: Router = Router(); -// TODO: Only permissions your bot has in the guild or channel can be allowed/denied (unless your bot has a MANAGE_ROLES overwrite in the channel) - -export interface ChannelPermissionOverwriteSchema extends ChannelPermissionOverwrite {} +const router: Router = Router(); router.put( "/:overwrite_id", diff --git a/api/src/routes/channels/#channel_id/purge.ts b/api/src/routes/channels/#channel_id/purge.ts index 7ab4ad9a..1ef6e1d7 100644 --- a/api/src/routes/channels/#channel_id/purge.ts +++ b/api/src/routes/channels/#channel_id/purge.ts @@ -1,4 +1,4 @@ -import { HTTPError } from "@fosscord/util"; +import { HTTPError, PurgeSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import { isTextChannel } from "./messages"; import { FindManyOptions, Between, Not } from "typeorm"; @@ -10,11 +10,6 @@ const router: Router = Router(); export default router; -export interface PurgeSchema { - before: string; - after: string; -} - /** TODO: apply the delete bit by bit to prevent client and database stress **/ diff --git a/api/src/routes/channels/#channel_id/webhooks.ts b/api/src/routes/channels/#channel_id/webhooks.ts index 00bf4619..b11c8eb9 100644 --- a/api/src/routes/channels/#channel_id/webhooks.ts +++ b/api/src/routes/channels/#channel_id/webhooks.ts @@ -6,14 +6,6 @@ import { isTextChannel } from "./messages/index"; import { DiscordApiErrors } from "@fosscord/util"; const router: Router = Router(); -// TODO: webhooks -export interface WebhookCreateSchema { - /** - * @maxLength 80 - */ - name: string; - avatar?: string; -} //TODO: implement webhooks router.get("/", route({}), async (req: Request, res: Response) => { res.json([]); diff --git a/api/src/routes/guilds/#guild_id/audit-logs.ts b/api/src/routes/guilds/#guild_id/audit-logs.ts index 7b1d0062..b54835fc 100644 --- a/api/src/routes/guilds/#guild_id/audit-logs.ts +++ b/api/src/routes/guilds/#guild_id/audit-logs.ts @@ -1,8 +1,5 @@ import { Router, Response, Request } from "express"; -import { Channel, ChannelUpdateEvent, getPermission, emitEvent } from "@fosscord/util"; -import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../../channels/#channel_id"; const router = Router(); //TODO: implement audit logs diff --git a/api/src/routes/guilds/#guild_id/bans.ts b/api/src/routes/guilds/#guild_id/bans.ts index 0743687d..3d405344 100644 --- a/api/src/routes/guilds/#guild_id/bans.ts +++ b/api/src/routes/guilds/#guild_id/bans.ts @@ -1,31 +1,9 @@ import { Request, Response, Router } from "express"; -import { DiscordApiErrors, emitEvent, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, Guild, Ban, User, Member } from "@fosscord/util"; +import { DiscordApiErrors, emitEvent, getPermission, GuildBanAddEvent, GuildBanRemoveEvent, Guild, Ban, User, Member, BanRegistrySchema, BanModeratorSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { getIpAdress, route } from "@fosscord/api"; import { OrmUtils } from "@fosscord/util"; -export interface BanCreateSchema { - delete_message_days?: string; - reason?: string; -}; - -export interface BanRegistrySchema { - id: string; - user_id: string; - guild_id: string; - executor_id: string; - ip?: string; - reason?: string | undefined; -}; - -export interface BanModeratorSchema { - id: string; - user_id: string; - guild_id: string; - executor_id: string; - reason?: string | undefined; -}; - const router: Router = Router(); /* TODO: Deleting the secrets is just a temporary go-around. Views should be implemented for both safety and better handling. */ diff --git a/api/src/routes/guilds/#guild_id/channels.ts b/api/src/routes/guilds/#guild_id/channels.ts index b952b474..df1b7924 100644 --- a/api/src/routes/guilds/#guild_id/channels.ts +++ b/api/src/routes/guilds/#guild_id/channels.ts @@ -1,8 +1,7 @@ import { Router, Response, Request } from "express"; -import { Channel, ChannelUpdateEvent, getPermission, emitEvent } from "@fosscord/util"; +import { Channel, ChannelUpdateEvent, getPermission, emitEvent, ChannelModifySchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../../channels/#channel_id"; const router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { diff --git a/api/src/routes/guilds/#guild_id/emojis.ts b/api/src/routes/guilds/#guild_id/emojis.ts index 53a44ec3..4bf4bdcd 100644 --- a/api/src/routes/guilds/#guild_id/emojis.ts +++ b/api/src/routes/guilds/#guild_id/emojis.ts @@ -1,22 +1,10 @@ import { Router, Request, Response } from "express"; -import { Config, DiscordApiErrors, emitEvent, Emoji, GuildEmojisUpdateEvent, handleFile, Member, Snowflake, User } from "@fosscord/util"; +import { Config, DiscordApiErrors, emitEvent, Emoji, EmojiCreateSchema, EmojiModifySchema, GuildEmojisUpdateEvent, handleFile, Member, Snowflake, User } from "@fosscord/util"; import { route } from "@fosscord/api"; import { OrmUtils } from "@fosscord/util"; const router = Router(); -export interface EmojiCreateSchema { - name?: string; - image: string; - require_colons?: boolean | null; - roles?: string[]; -} - -export interface EmojiModifySchema { - name?: string; - roles?: string[]; -} - router.get("/", route({}), async (req: Request, res: Response) => { const { guild_id } = req.params; diff --git a/api/src/routes/guilds/#guild_id/index.ts b/api/src/routes/guilds/#guild_id/index.ts index 8d61f753..a9712c71 100644 --- a/api/src/routes/guilds/#guild_id/index.ts +++ b/api/src/routes/guilds/#guild_id/index.ts @@ -1,29 +1,11 @@ import { Request, Response, Router } from "express"; -import { DiscordApiErrors, emitEvent, getPermission, getRights, Guild, GuildUpdateEvent, handleFile, Member } from "@fosscord/util"; +import { DiscordApiErrors, emitEvent, getPermission, getRights, Guild, GuildUpdateEvent, GuildUpdateSchema, handleFile, Member } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { GuildCreateSchema } from "../index"; import { OrmUtils } from "@fosscord/util"; const router = Router(); -export interface GuildUpdateSchema extends Omit { - name?: string; - banner?: string | null; - splash?: string | null; - description?: string; - features?: string[]; - verification_level?: number; - default_message_notifications?: number; - system_channel_flags?: number; - explicit_content_filter?: number; - public_updates_channel_id?: string; - afk_timeout?: number; - afk_channel_id?: string; - preferred_locale?: string; - premium_progress_bar_enabled?: boolean; -} - router.get("/", route({}), async (req: Request, res: Response) => { const { guild_id } = req.params; diff --git a/api/src/routes/guilds/#guild_id/integrations.ts b/api/src/routes/guilds/#guild_id/integrations.ts index 19f68563..90650111 100644 --- a/api/src/routes/guilds/#guild_id/integrations.ts +++ b/api/src/routes/guilds/#guild_id/integrations.ts @@ -2,7 +2,6 @@ import { Router, Response, Request } from "express"; import { Channel, ChannelUpdateEvent, getPermission, emitEvent } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../../channels/#channel_id"; const router = Router(); //TODO: implement integrations list diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts index 824e34a4..794369d8 100644 --- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts +++ b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts @@ -1,15 +1,11 @@ import { Request, Response, Router } from "express"; -import { Member, getPermission, getRights, Role, GuildMemberUpdateEvent, emitEvent, Sticker, Emoji, Rights, Guild } from "@fosscord/util"; +import { Member, getPermission, getRights, Role, GuildMemberUpdateEvent, emitEvent, Sticker, Emoji, Rights, Guild, MemberChangeSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; import { OrmUtils } from "@fosscord/util"; const router = Router(); -export interface MemberChangeSchema { - roles?: string[]; -} - router.get("/", route({}), async (req: Request, res: Response) => { const { guild_id, member_id } = req.params; await Member.IsInGuildOrFail(req.user_id, guild_id); diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts b/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts index 4dfae8da..a6c71333 100644 --- a/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts +++ b/api/src/routes/guilds/#guild_id/members/#member_id/nick.ts @@ -4,10 +4,6 @@ import { Request, Response, Router } from "express"; const router = Router(); -export interface MemberNickChangeSchema { - nick: string; -} - router.patch("/", route({ body: "MemberNickChangeSchema" }), async (req: Request, res: Response) => { let { guild_id, member_id } = req.params; let permissionString: PermissionResolvable = "MANAGE_NICKNAMES"; diff --git a/api/src/routes/guilds/#guild_id/prune.ts b/api/src/routes/guilds/#guild_id/prune.ts index 01f18ce4..673f022f 100644 --- a/api/src/routes/guilds/#guild_id/prune.ts +++ b/api/src/routes/guilds/#guild_id/prune.ts @@ -62,13 +62,6 @@ router.get("/", route({}), async (req: Request, res: Response) => { res.send({ pruned: members.length }); }); -export interface PruneSchema { - /** - * @min 0 - */ - days: number; -} - router.post("/", route({ permission: "KICK_MEMBERS", right: "KICK_BAN_MEMBERS" }), async (req: Request, res: Response) => { const days = parseInt(req.body.days); diff --git a/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts b/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts index 0482b9ca..d4422a9c 100644 --- a/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts +++ b/api/src/routes/guilds/#guild_id/roles/#role_id/index.ts @@ -1,8 +1,7 @@ import { Router, Request, Response } from "express"; -import { Role, Member, GuildRoleUpdateEvent, GuildRoleDeleteEvent, emitEvent, handleFile } from "@fosscord/util"; +import { Role, Member, GuildRoleUpdateEvent, GuildRoleDeleteEvent, emitEvent, handleFile, RoleModifySchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import { HTTPError } from "@fosscord/util"; -import { RoleModifySchema } from "../"; import { OrmUtils } from "@fosscord/util"; const router = Router(); diff --git a/api/src/routes/guilds/#guild_id/roles/index.ts b/api/src/routes/guilds/#guild_id/roles/index.ts index 6fbb8702..effa4fcd 100644 --- a/api/src/routes/guilds/#guild_id/roles/index.ts +++ b/api/src/routes/guilds/#guild_id/roles/index.ts @@ -9,7 +9,8 @@ import { emitEvent, Config, DiscordApiErrors, - handleFile + handleFile, + RoleModifySchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; @@ -17,17 +18,6 @@ import { OrmUtils } from "@fosscord/util"; const router: Router = Router(); -export interface RoleModifySchema { - name?: string; - permissions?: string; - color?: number; - hoist?: boolean; // whether the role should be displayed separately in the sidebar - mentionable?: boolean; // whether the role should be mentionable - position?: number; - icon?: string; - unicode_emoji?: string; -} - export type RolePositionUpdateSchema = { id: string; position: number; diff --git a/api/src/routes/guilds/#guild_id/stickers.ts b/api/src/routes/guilds/#guild_id/stickers.ts index 157ccff4..71c9dfcd 100644 --- a/api/src/routes/guilds/#guild_id/stickers.ts +++ b/api/src/routes/guilds/#guild_id/stickers.ts @@ -3,6 +3,7 @@ import { GuildStickersUpdateEvent, handleFile, Member, + ModifyGuildStickerSchema, Snowflake, Sticker, StickerFormatType, @@ -83,22 +84,6 @@ router.get("/:sticker_id", route({}), async (req: Request, res: Response) => { res.json(await Sticker.findOneOrFail({ where: { guild_id, id: sticker_id } })); }); -export interface ModifyGuildStickerSchema { - /** - * @minLength 2 - * @maxLength 30 - */ - name: string; - /** - * @maxLength 100 - */ - description?: string; - /** - * @maxLength 200 - */ - tags: string; -} - router.patch( "/:sticker_id", route({ body: "ModifyGuildStickerSchema", permission: "MANAGE_EMOJIS_AND_STICKERS" }), diff --git a/api/src/routes/guilds/#guild_id/templates.ts b/api/src/routes/guilds/#guild_id/templates.ts index 3d14de41..9c79692d 100644 --- a/api/src/routes/guilds/#guild_id/templates.ts +++ b/api/src/routes/guilds/#guild_id/templates.ts @@ -24,16 +24,6 @@ const TemplateGuildProjection: (keyof Guild)[] = [ "icon" ]; -export interface TemplateCreateSchema { - name: string; - description?: string; -} - -export interface TemplateModifySchema { - name: string; - description?: string; -} - router.get("/", route({}), async (req: Request, res: Response) => { const { guild_id } = req.params; diff --git a/api/src/routes/guilds/#guild_id/vanity-url.ts b/api/src/routes/guilds/#guild_id/vanity-url.ts index ac46e18a..ff92ce8d 100644 --- a/api/src/routes/guilds/#guild_id/vanity-url.ts +++ b/api/src/routes/guilds/#guild_id/vanity-url.ts @@ -1,4 +1,4 @@ -import { Channel, ChannelType, getPermission, Guild, Invite, trimSpecial } from "@fosscord/util"; +import { Channel, ChannelType, getPermission, Guild, Invite, trimSpecial, VanityUrlSchema } from "@fosscord/util"; import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; import { HTTPError } from "@fosscord/util"; @@ -25,14 +25,6 @@ router.get("/", route({ permission: "MANAGE_GUILD" }), async (req: Request, res: } }); -export interface VanityUrlSchema { - /** - * @minLength 1 - * @maxLength 20 - */ - code?: string; -} - router.patch("/", route({ body: "VanityUrlSchema", permission: "MANAGE_GUILD" }), async (req: Request, res: Response) => { const { guild_id } = req.params; const body = req.body as VanityUrlSchema; diff --git a/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts b/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts index 32d1aadf..28a9e8c1 100644 --- a/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts +++ b/api/src/routes/guilds/#guild_id/voice-states/#user_id/index.ts @@ -1,21 +1,9 @@ -import { Channel, ChannelType, DiscordApiErrors, emitEvent, getPermission, VoiceState, VoiceStateUpdateEvent } from "@fosscord/util"; +import { Channel, ChannelType, DiscordApiErrors, emitEvent, getPermission, VoiceState, VoiceStateUpdateEvent, VoiceStateUpdateSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import { Request, Response, Router } from "express"; import { OrmUtils } from "@fosscord/util"; const router = Router(); -//TODO need more testing when community guild and voice stage channel are working - -export interface VoiceStateUpdateSchema { - channel_id: string; - guild_id?: string; - suppress?: boolean; - request_to_speak_timestamp?: Date; - self_mute?: boolean; - self_deaf?: boolean; - self_video?: boolean; -} - router.patch("/", route({ body: "VoiceStateUpdateSchema" }), async (req: Request, res: Response) => { const body = req.body as VoiceStateUpdateSchema; let { guild_id, user_id } = req.params; diff --git a/api/src/routes/guilds/#guild_id/webhooks.ts b/api/src/routes/guilds/#guild_id/webhooks.ts index 7f5b9592..c8c1eb5c 100644 --- a/api/src/routes/guilds/#guild_id/webhooks.ts +++ b/api/src/routes/guilds/#guild_id/webhooks.ts @@ -2,7 +2,6 @@ import { Router, Response, Request } from "express"; import { Channel, ChannelUpdateEvent, getPermission, emitEvent } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../../channels/#channel_id"; const router = Router(); //TODO: implement webhooks diff --git a/api/src/routes/guilds/#guild_id/welcome_screen.ts b/api/src/routes/guilds/#guild_id/welcome_screen.ts index 4093ec1d..d08300ba 100644 --- a/api/src/routes/guilds/#guild_id/welcome_screen.ts +++ b/api/src/routes/guilds/#guild_id/welcome_screen.ts @@ -1,21 +1,10 @@ import { Request, Response, Router } from "express"; -import { Guild, getPermission, Snowflake, Member } from "@fosscord/util"; +import { Guild, getPermission, Snowflake, Member, GuildUpdateWelcomeScreenSchema } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import { route } from "@fosscord/api"; const router: Router = Router(); -export interface GuildUpdateWelcomeScreenSchema { - welcome_channels?: { - channel_id: string; - description: string; - emoji_id?: string; - emoji_name: string; - }[]; - enabled?: boolean; - description?: string; -} - router.get("/", route({}), async (req: Request, res: Response) => { const guild_id = req.params.guild_id; diff --git a/api/src/routes/guilds/#guild_id/widget.ts b/api/src/routes/guilds/#guild_id/widget.ts index 103f84a3..dbb4cc0c 100644 --- a/api/src/routes/guilds/#guild_id/widget.ts +++ b/api/src/routes/guilds/#guild_id/widget.ts @@ -1,12 +1,7 @@ import { Request, Response, Router } from "express"; -import { Guild } from "@fosscord/util"; +import { Guild, WidgetModifySchema } from "@fosscord/util"; import { route } from "@fosscord/api"; -export interface WidgetModifySchema { - enabled: boolean; // whether the widget is enabled - channel_id: string; // the widget channel id -} - const router: Router = Router(); // https://discord.com/developers/docs/resources/guild#get-guild-widget-settings diff --git a/api/src/routes/guilds/index.ts b/api/src/routes/guilds/index.ts index 64b9454b..e4d66192 100644 --- a/api/src/routes/guilds/index.ts +++ b/api/src/routes/guilds/index.ts @@ -1,23 +1,9 @@ import { Router, Request, Response } from "express"; -import { Role, Guild, Snowflake, Config, getRights, Member, Channel, DiscordApiErrors, handleFile } from "@fosscord/util"; +import { Role, Guild, Snowflake, Config, getRights, Member, Channel, DiscordApiErrors, handleFile, GuildCreateSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { ChannelModifySchema } from "../channels/#channel_id"; const router: Router = Router(); -export interface GuildCreateSchema { - /** - * @maxLength 100 - */ - name: string; - region?: string; - icon?: string | null; - channels?: ChannelModifySchema[]; - guild_template_code?: string; - system_channel_id?: string; - rules_channel_id?: string; -} - //TODO: create default channel router.post("/", route({ body: "GuildCreateSchema", right: "CREATE_GUILDS" }), async (req: Request, res: Response) => { diff --git a/api/src/routes/guilds/templates/index.ts b/api/src/routes/guilds/templates/index.ts index bac4eb8a..3a0de9e8 100644 --- a/api/src/routes/guilds/templates/index.ts +++ b/api/src/routes/guilds/templates/index.ts @@ -1,15 +1,8 @@ import { Request, Response, Router } from "express"; -import { Template, Guild, Role, Snowflake, Config, User, Member } from "@fosscord/util"; +import { Template, Guild, Role, Snowflake, Config, User, Member, DiscordApiErrors, OrmUtils, GuildTemplateCreateSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; -import { DiscordApiErrors } from "@fosscord/util"; import fetch from "node-fetch"; const router: Router = Router(); -import { OrmUtils } from "@fosscord/util"; - -export interface GuildTemplateCreateSchema { - name: string; - avatar?: string | null; -} router.get("/:code", route({}), async (req: Request, res: Response) => { const { allowDiscordTemplates, allowRaws, enabled } = Config.get().templates; diff --git a/api/src/routes/users/@me/channels.ts b/api/src/routes/users/@me/channels.ts index 78f531e1..ad483529 100644 --- a/api/src/routes/users/@me/channels.ts +++ b/api/src/routes/users/@me/channels.ts @@ -1,5 +1,5 @@ import { Request, Response, Router } from "express"; -import { Recipient, DmChannelDTO, Channel } from "@fosscord/util"; +import { Recipient, DmChannelDTO, Channel, DmChannelCreateSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; const router: Router = Router(); @@ -12,11 +12,6 @@ router.get("/", route({}), async (req: Request, res: Response) => { res.json(await Promise.all(recipients.map((r) => DmChannelDTO.from(r.channel, [req.user_id])))); }); -export interface DmChannelCreateSchema { - name?: string; - recipients: string[]; -} - router.post("/", route({ body: "DmChannelCreateSchema" }), async (req: Request, res: Response) => { const body = req.body as DmChannelCreateSchema; res.json(await Channel.createDMChannel(body.recipients, req.user_id, body.name)); diff --git a/api/src/routes/users/@me/index.ts b/api/src/routes/users/@me/index.ts index 4cf96a8d..7d095451 100644 --- a/api/src/routes/users/@me/index.ts +++ b/api/src/routes/users/@me/index.ts @@ -1,30 +1,11 @@ import { Router, Request, Response } from "express"; -import { User, PrivateUserProjection, emitEvent, UserUpdateEvent, handleFile, FieldErrors } from "@fosscord/util"; +import { User, PrivateUserProjection, emitEvent, UserUpdateEvent, handleFile, FieldErrors, UserModifySchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import bcrypt from "bcrypt"; import { OrmUtils, generateToken } from "@fosscord/util"; const router: Router = Router(); -export interface UserModifySchema { - /** - * @minLength 1 - * @maxLength 100 - */ - username?: string; - discriminator?: string; - avatar?: string | null; - /** - * @maxLength 1024 - */ - bio?: string; - accent_color?: number; - banner?: string | null; - password?: string; - new_password?: string; - code?: string; -} - router.get("/", route({}), async (req: Request, res: Response) => { res.json(await User.findOne({ select: PrivateUserProjection, where: { id: req.user_id } })); }); diff --git a/api/src/routes/users/@me/mfa/codes.ts b/api/src/routes/users/@me/mfa/codes.ts index 75e3e964..4224a1c0 100644 --- a/api/src/routes/users/@me/mfa/codes.ts +++ b/api/src/routes/users/@me/mfa/codes.ts @@ -1,15 +1,10 @@ import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; -import { BackupCode, Config, FieldErrors, generateMfaBackupCodes, User } from "@fosscord/util"; +import { BackupCode, Config, FieldErrors, generateMfaBackupCodes, MfaCodesSchema, User } from "@fosscord/util"; import bcrypt from "bcrypt"; const router = Router(); -export interface MfaCodesSchema { - password: string; - regenerate?: boolean; -} - // TODO: This route is replaced with users/@me/mfa/codes-verification in newer clients router.post("/", route({ body: "MfaCodesSchema" }), async (req: Request, res: Response) => { diff --git a/api/src/routes/users/@me/mfa/totp/disable.ts b/api/src/routes/users/@me/mfa/totp/disable.ts index 2d385fda..2fe9355c 100644 --- a/api/src/routes/users/@me/mfa/totp/disable.ts +++ b/api/src/routes/users/@me/mfa/totp/disable.ts @@ -2,14 +2,10 @@ import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; import { verifyToken } from 'node-2fa'; import { HTTPError } from "lambert-server"; -import { User, generateToken, BackupCode } from "@fosscord/util"; +import { User, generateToken, BackupCode, TotpDisableSchema } from "@fosscord/util"; const router = Router(); -export interface TotpDisableSchema { - code: string; -} - router.post("/", route({ body: "TotpDisableSchema" }), async (req: Request, res: Response) => { const body = req.body as TotpDisableSchema; diff --git a/api/src/routes/users/@me/mfa/totp/enable.ts b/api/src/routes/users/@me/mfa/totp/enable.ts index 87f36d55..ac668d1d 100644 --- a/api/src/routes/users/@me/mfa/totp/enable.ts +++ b/api/src/routes/users/@me/mfa/totp/enable.ts @@ -1,5 +1,5 @@ import { Router, Request, Response } from "express"; -import { User, generateToken, BackupCode, generateMfaBackupCodes, Config } from "@fosscord/util"; +import { User, generateToken, BackupCode, generateMfaBackupCodes, Config, TotpEnableSchema } from "@fosscord/util"; import { route } from "@fosscord/api"; import bcrypt from "bcrypt"; import { HTTPError } from "lambert-server"; @@ -7,12 +7,6 @@ import { verifyToken } from 'node-2fa'; const router = Router(); -export interface TotpEnableSchema { - password: string; - code?: string; - secret?: string; -} - router.post("/", route({ body: "TotpEnableSchema" }), async (req: Request, res: Response) => { const body = req.body as TotpEnableSchema; diff --git a/api/src/routes/users/@me/relationships.ts b/api/src/routes/users/@me/relationships.ts index 6e22f4f3..f7464b99 100644 --- a/api/src/routes/users/@me/relationships.ts +++ b/api/src/routes/users/@me/relationships.ts @@ -38,10 +38,6 @@ router.get("/", route({}), async (req: Request, res: Response) => { return res.json(related_users); }); -export interface RelationshipPutSchema { - type?: RelationshipType; -} - router.put("/:id", route({ body: "RelationshipPutSchema" }), async (req: Request, res: Response) => { return await updateRelationship( req, @@ -51,11 +47,6 @@ router.put("/:id", route({ body: "RelationshipPutSchema" }), async (req: Request ); }); -export interface RelationshipPostSchema { - discriminator: string; - username: string; -} - router.post("/", route({ body: "RelationshipPostSchema" }), async (req: Request, res: Response) => { return await updateRelationship( req, diff --git a/api/src/routes/users/@me/settings.ts b/api/src/routes/users/@me/settings.ts index d832575f..7578d36e 100644 --- a/api/src/routes/users/@me/settings.ts +++ b/api/src/routes/users/@me/settings.ts @@ -4,8 +4,6 @@ import { route } from "@fosscord/api"; const router = Router(); -export interface UserSettingsSchema extends Partial {} - router.patch("/", route({ body: "UserSettingsSchema" }), async (req: Request, res: Response) => { const body = req.body as UserSettings; if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale diff --git a/api/src/util/handlers/Message.ts b/api/src/util/handlers/Message.ts index 0f584c56..ff5ece75 100644 --- a/api/src/util/handlers/Message.ts +++ b/api/src/util/handlers/Message.ts @@ -21,12 +21,13 @@ import { Webhook, Attachment, Config, + MessageCreateSchema, } from "@fosscord/util"; import { HTTPError } from "@fosscord/util"; import fetch from "node-fetch"; import cheerio from "cheerio"; -import { MessageCreateSchema } from "../../routes/channels/#channel_id/messages"; import { OrmUtils } from "@fosscord/util"; + const allow_empty = false; // TODO: check webhook, application, system author, stickers // TODO: embed gifs/videos/images diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts index ce4385a3..e62c1570 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts @@ -19,12 +19,12 @@ import { MemberPrivateProjection, PresenceUpdateEvent, UserSettings, + IdentifySchema, } from "@fosscord/util"; import { Send } from "../util/Send"; import { CLOSECODES, OPCODES } from "../util/Constants"; import { genSessionId } from "../util/SessionUtils"; import { setupListener } from "../listener/listener"; -import { IdentifySchema } from "../schema/Identify"; // import experiments from "./experiments.json"; const experiments: any = []; import { check } from "./instanceOf"; diff --git a/gateway/src/opcodes/LazyRequest.ts b/gateway/src/opcodes/LazyRequest.ts index 5ba65cdd..cd0586de 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/gateway/src/opcodes/LazyRequest.ts @@ -1,5 +1,4 @@ -import { getPermission, listenEvent, Member, Role, getOrInitialiseDatabase } from "@fosscord/util"; -import { LazyRequest } from "../schema/LazyRequest"; +import { getPermission, listenEvent, Member, Role, getOrInitialiseDatabase, LazyRequest } from "@fosscord/util"; import { Send } from "../util/Send"; import { OPCODES } from "../util/Constants"; import { WebSocket, Payload, handlePresenceUpdate } from "@fosscord/gateway"; diff --git a/gateway/src/opcodes/PresenceUpdate.ts b/gateway/src/opcodes/PresenceUpdate.ts index 415df6ee..f31c9161 100644 --- a/gateway/src/opcodes/PresenceUpdate.ts +++ b/gateway/src/opcodes/PresenceUpdate.ts @@ -1,6 +1,5 @@ import { WebSocket, Payload } from "@fosscord/gateway"; -import { emitEvent, PresenceUpdateEvent, Session, User } from "@fosscord/util"; -import { ActivitySchema } from "../schema/Activity"; +import { ActivitySchema, emitEvent, PresenceUpdateEvent, Session, User } from "@fosscord/util"; import { check } from "./instanceOf"; export async function onPresenceUpdate(this: WebSocket, { d }: Payload) { diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/gateway/src/opcodes/VoiceStateUpdate.ts index 845a75c0..73f73565 100644 --- a/gateway/src/opcodes/VoiceStateUpdate.ts +++ b/gateway/src/opcodes/VoiceStateUpdate.ts @@ -1,4 +1,3 @@ -import { VoiceStateUpdateSchema } from "../schema/VoiceStateUpdateSchema"; import { Payload, WebSocket } from "@fosscord/gateway"; import { genVoiceToken } from "../util/SessionUtils"; import { check } from "./instanceOf"; @@ -10,6 +9,7 @@ import { VoiceServerUpdateEvent, VoiceState, VoiceStateUpdateEvent, + VoiceStateUpdateSchema, } from "@fosscord/util"; import { OrmUtils } from "@fosscord/util"; import { Region } from "@fosscord/util/src/config"; diff --git a/gateway/src/schema/Activity.ts b/gateway/src/schema/Activity.ts deleted file mode 100644 index e18f66c8..00000000 --- a/gateway/src/schema/Activity.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Activity, Status } from "@fosscord/util"; - -export const ActivitySchema = { - afk: Boolean, - status: String, - $activities: [ - { - name: String, - type: Number, - $url: String, - $created_at: Date, - $timestamps: { - $start: Number, - $end: Number, - }, - $application_id: String, - $details: String, - $state: String, - $emoji: { - $name: String, - $id: String, - $animated: Boolean, - }, - $party: { - $id: String, - $size: [Number, Number], - }, - $assets: { - $large_image: String, - $large_text: String, - $small_image: String, - $small_text: String, - }, - $secrets: { - $join: String, - $spectate: String, - $match: String, - }, - $instance: Boolean, - $flags: String, - }, - ], - $since: Number, // unix time (in milliseconds) of when the client went idle, or null if the client is not idle -}; - -export interface ActivitySchema { - afk: boolean; - status: Status; - activities?: Activity[]; - since?: number; // unix time (in milliseconds) of when the client went idle, or null if the client is not idle -} diff --git a/gateway/src/schema/Identify.ts b/gateway/src/schema/Identify.ts deleted file mode 100644 index 21141321..00000000 --- a/gateway/src/schema/Identify.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { ActivitySchema } from "./Activity"; - -export const IdentifySchema = { - token: String, - $intents: BigInt, // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt - $properties: Object, - // { - // // discord uses $ in the property key for bots, so we need to double prefix it, because instanceOf treats $ (prefix) as a optional key - // $os: String, - // $os_arch: String, - // $browser: String, - // $device: String, - // $$os: String, - // $$browser: String, - // $$device: String, - // $browser_user_agent: String, - // $browser_version: String, - // $os_version: String, - // $referrer: String, - // $$referrer: String, - // $referring_domain: String, - // $$referring_domain: String, - // $referrer_current: String, - // $referring_domain_current: String, - // $release_channel: String, - // $client_build_number: Number, - // $client_event_source: String, - // $client_version: String, - // $system_locale: String, - // $window_manager: String, - // $distro: String, - // }, - $presence: ActivitySchema, - $compress: Boolean, - $large_threshold: Number, - $shard: [BigInt, BigInt], - $guild_subscriptions: Boolean, - $capabilities: Number, - $client_state: { - $guild_hashes: Object, - $highest_last_message_id: String, - $read_state_version: Number, - $user_guild_settings_version: Number, - $user_settings_version: undefined, - }, - $v: Number, - $version: Number, -}; - -export interface IdentifySchema { - token: string; - properties: { - // bruh discord really uses $ in the property key, so we need to double prefix it, because instanceOf treats $ (prefix) as a optional key - os?: string; - os_atch?: string; - browser?: string; - device?: string; - $os?: string; - $browser?: string; - $device?: string; - browser_user_agent?: string; - browser_version?: string; - os_version?: string; - referrer?: string; - referring_domain?: string; - referrer_current?: string; - referring_domain_current?: string; - release_channel?: "stable" | "dev" | "ptb" | "canary"; - client_build_number?: number; - client_event_source?: any; - client_version?: string; - system_locale?: string; - }; - intents?: bigint; // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt - presence?: ActivitySchema; - compress?: boolean; - large_threshold?: number; - shard?: [bigint, bigint]; - guild_subscriptions?: boolean; - capabilities?: number; - client_state?: { - guild_hashes?: any; - highest_last_message_id?: string; - read_state_version?: number; - user_guild_settings_version?: number; - user_settings_version?: number; - }; - v?: number; -} diff --git a/gateway/src/schema/LazyRequest.ts b/gateway/src/schema/LazyRequest.ts deleted file mode 100644 index 1fe658bb..00000000 --- a/gateway/src/schema/LazyRequest.ts +++ /dev/null @@ -1,19 +0,0 @@ -export interface LazyRequest { - guild_id: string; - channels?: Record; - activities?: boolean; - threads?: boolean; - typing?: true; - members?: any[]; - thread_member_lists?: any[]; -} - -export const LazyRequest = { - guild_id: String, - $activities: Boolean, - $channels: Object, - $typing: Boolean, - $threads: Boolean, - $members: [] as any[], - $thread_member_lists: [] as any[], -}; diff --git a/gateway/src/schema/VoiceStateUpdateSchema.ts b/gateway/src/schema/VoiceStateUpdateSchema.ts deleted file mode 100644 index 9efa191e..00000000 --- a/gateway/src/schema/VoiceStateUpdateSchema.ts +++ /dev/null @@ -1,15 +0,0 @@ -export const VoiceStateUpdateSchema = { - $guild_id: String, - $channel_id: String, - self_mute: Boolean, - self_deaf: Boolean, - self_video: Boolean, -}; - -export interface VoiceStateUpdateSchema { - guild_id?: string; - channel_id?: string; - self_mute: boolean; - self_deaf: boolean; - self_video: boolean; -} diff --git a/util/src/index.ts b/util/src/index.ts index 259d1c97..daeffd69 100644 --- a/util/src/index.ts +++ b/util/src/index.ts @@ -4,4 +4,5 @@ export * from "./util/index"; export * from "./interfaces/index"; export * from "./entities/index"; export * from "./dtos/index"; -export * from "./util/MFA"; \ No newline at end of file +export * from "./util/MFA"; +export * from "./schemas"; \ No newline at end of file diff --git a/util/src/schemas/ActivitySchema.ts b/util/src/schemas/ActivitySchema.ts new file mode 100644 index 00000000..e18f66c8 --- /dev/null +++ b/util/src/schemas/ActivitySchema.ts @@ -0,0 +1,51 @@ +import { Activity, Status } from "@fosscord/util"; + +export const ActivitySchema = { + afk: Boolean, + status: String, + $activities: [ + { + name: String, + type: Number, + $url: String, + $created_at: Date, + $timestamps: { + $start: Number, + $end: Number, + }, + $application_id: String, + $details: String, + $state: String, + $emoji: { + $name: String, + $id: String, + $animated: Boolean, + }, + $party: { + $id: String, + $size: [Number, Number], + }, + $assets: { + $large_image: String, + $large_text: String, + $small_image: String, + $small_text: String, + }, + $secrets: { + $join: String, + $spectate: String, + $match: String, + }, + $instance: Boolean, + $flags: String, + }, + ], + $since: Number, // unix time (in milliseconds) of when the client went idle, or null if the client is not idle +}; + +export interface ActivitySchema { + afk: boolean; + status: Status; + activities?: Activity[]; + since?: number; // unix time (in milliseconds) of when the client went idle, or null if the client is not idle +} diff --git a/util/src/schemas/BanCreateSchema.ts b/util/src/schemas/BanCreateSchema.ts new file mode 100644 index 00000000..64b02943 --- /dev/null +++ b/util/src/schemas/BanCreateSchema.ts @@ -0,0 +1,5 @@ + +export interface BanCreateSchema { + delete_message_days?: string; + reason?: string; +} diff --git a/util/src/schemas/BanModeratorSchema.ts b/util/src/schemas/BanModeratorSchema.ts new file mode 100644 index 00000000..b497d319 --- /dev/null +++ b/util/src/schemas/BanModeratorSchema.ts @@ -0,0 +1,8 @@ + +export interface BanModeratorSchema { + id: string; + user_id: string; + guild_id: string; + executor_id: string; + reason?: string | undefined; +} diff --git a/util/src/schemas/BanRegistrySchema.ts b/util/src/schemas/BanRegistrySchema.ts new file mode 100644 index 00000000..661f934f --- /dev/null +++ b/util/src/schemas/BanRegistrySchema.ts @@ -0,0 +1,9 @@ + +export interface BanRegistrySchema { + id: string; + user_id: string; + guild_id: string; + executor_id: string; + ip?: string; + reason?: string | undefined; +} diff --git a/util/src/schemas/BulkDeleteSchema.ts b/util/src/schemas/BulkDeleteSchema.ts new file mode 100644 index 00000000..26f88374 --- /dev/null +++ b/util/src/schemas/BulkDeleteSchema.ts @@ -0,0 +1,4 @@ + +export interface BulkDeleteSchema { + messages: string[]; +} diff --git a/util/src/schemas/ChannelModifySchema.ts b/util/src/schemas/ChannelModifySchema.ts new file mode 100644 index 00000000..3cfcf7d2 --- /dev/null +++ b/util/src/schemas/ChannelModifySchema.ts @@ -0,0 +1,29 @@ +import { ChannelPermissionOverwriteType, ChannelType } from ".."; + + +export interface ChannelModifySchema { + /** + * @maxLength 100 + */ + name?: string; + type?: ChannelType; + topic?: string; + icon?: string | null; + bitrate?: number; + user_limit?: number; + rate_limit_per_user?: number; + position?: number; + permission_overwrites?: { + id: string; + type: ChannelPermissionOverwriteType; + allow: string; + deny: string; + }[]; + parent_id?: string; + id?: string; // is not used (only for guild create) + nsfw?: boolean; + rtc_region?: string; + default_auto_archive_duration?: number; + flags?: number; + default_thread_rate_limit_per_user?: number; +} \ No newline at end of file diff --git a/util/src/schemas/ChannelPermissionOverwriteSchema.ts b/util/src/schemas/ChannelPermissionOverwriteSchema.ts new file mode 100644 index 00000000..fe9ba860 --- /dev/null +++ b/util/src/schemas/ChannelPermissionOverwriteSchema.ts @@ -0,0 +1,5 @@ +import { ChannelPermissionOverwrite } from "@fosscord/util"; + +// TODO: Only permissions your bot has in the guild or channel can be allowed/denied (unless your bot has a MANAGE_ROLES overwrite in the channel) + +export interface ChannelPermissionOverwriteSchema extends ChannelPermissionOverwrite { } diff --git a/util/src/schemas/DmChannelCreateSchema.ts b/util/src/schemas/DmChannelCreateSchema.ts new file mode 100644 index 00000000..d5afc6d7 --- /dev/null +++ b/util/src/schemas/DmChannelCreateSchema.ts @@ -0,0 +1,5 @@ + +export interface DmChannelCreateSchema { + name?: string; + recipients: string[]; +} diff --git a/util/src/schemas/EmojiCreateSchema.ts b/util/src/schemas/EmojiCreateSchema.ts new file mode 100644 index 00000000..d50c419c --- /dev/null +++ b/util/src/schemas/EmojiCreateSchema.ts @@ -0,0 +1,7 @@ + +export interface EmojiCreateSchema { + name?: string; + image: string; + require_colons?: boolean | null; + roles?: string[]; +} diff --git a/util/src/schemas/EmojiModifySchema.ts b/util/src/schemas/EmojiModifySchema.ts new file mode 100644 index 00000000..5529dbd5 --- /dev/null +++ b/util/src/schemas/EmojiModifySchema.ts @@ -0,0 +1,5 @@ + +export interface EmojiModifySchema { + name?: string; + roles?: string[]; +} diff --git a/util/src/schemas/GuildCreateSchema.ts b/util/src/schemas/GuildCreateSchema.ts new file mode 100644 index 00000000..e4855119 --- /dev/null +++ b/util/src/schemas/GuildCreateSchema.ts @@ -0,0 +1,14 @@ +import { ChannelModifySchema } from "."; + +export interface GuildCreateSchema { + /** + * @maxLength 100 + */ + name: string; + region?: string; + icon?: string | null; + channels?: ChannelModifySchema[]; + guild_template_code?: string; + system_channel_id?: string; + rules_channel_id?: string; +} diff --git a/util/src/schemas/GuildTemplateCreateSchema.ts b/util/src/schemas/GuildTemplateCreateSchema.ts new file mode 100644 index 00000000..1579001e --- /dev/null +++ b/util/src/schemas/GuildTemplateCreateSchema.ts @@ -0,0 +1,5 @@ + +export interface GuildTemplateCreateSchema { + name: string; + avatar?: string | null; +} diff --git a/util/src/schemas/GuildUpdateSchema.ts b/util/src/schemas/GuildUpdateSchema.ts new file mode 100644 index 00000000..86527cf1 --- /dev/null +++ b/util/src/schemas/GuildUpdateSchema.ts @@ -0,0 +1,18 @@ +import { GuildCreateSchema } from "."; + +export interface GuildUpdateSchema extends Omit { + name?: string; + banner?: string | null; + splash?: string | null; + description?: string; + features?: string[]; + verification_level?: number; + default_message_notifications?: number; + system_channel_flags?: number; + explicit_content_filter?: number; + public_updates_channel_id?: string; + afk_timeout?: number; + afk_channel_id?: string; + preferred_locale?: string; + premium_progress_bar_enabled?: boolean; +} diff --git a/util/src/schemas/GuildUpdateWelcomeScreenSchema.ts b/util/src/schemas/GuildUpdateWelcomeScreenSchema.ts new file mode 100644 index 00000000..b1e36920 --- /dev/null +++ b/util/src/schemas/GuildUpdateWelcomeScreenSchema.ts @@ -0,0 +1,11 @@ + +export interface GuildUpdateWelcomeScreenSchema { + welcome_channels?: { + channel_id: string; + description: string; + emoji_id?: string; + emoji_name: string; + }[]; + enabled?: boolean; + description?: string; +} diff --git a/util/src/schemas/IdentifySchema.ts b/util/src/schemas/IdentifySchema.ts new file mode 100644 index 00000000..8f95c6a0 --- /dev/null +++ b/util/src/schemas/IdentifySchema.ts @@ -0,0 +1,89 @@ +import { ActivitySchema } from "./ActivitySchema"; + +export const IdentifySchema = { + token: String, + $intents: BigInt, // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt + $properties: Object, + // { + // // discord uses $ in the property key for bots, so we need to double prefix it, because instanceOf treats $ (prefix) as a optional key + // $os: String, + // $os_arch: String, + // $browser: String, + // $device: String, + // $$os: String, + // $$browser: String, + // $$device: String, + // $browser_user_agent: String, + // $browser_version: String, + // $os_version: String, + // $referrer: String, + // $$referrer: String, + // $referring_domain: String, + // $$referring_domain: String, + // $referrer_current: String, + // $referring_domain_current: String, + // $release_channel: String, + // $client_build_number: Number, + // $client_event_source: String, + // $client_version: String, + // $system_locale: String, + // $window_manager: String, + // $distro: String, + // }, + $presence: ActivitySchema, + $compress: Boolean, + $large_threshold: Number, + $shard: [BigInt, BigInt], + $guild_subscriptions: Boolean, + $capabilities: Number, + $client_state: { + $guild_hashes: Object, + $highest_last_message_id: String, + $read_state_version: Number, + $user_guild_settings_version: Number, + $user_settings_version: undefined, + }, + $v: Number, + $version: Number, +}; + +export interface IdentifySchema { + token: string; + properties: { + // bruh discord really uses $ in the property key, so we need to double prefix it, because instanceOf treats $ (prefix) as a optional key + os?: string; + os_atch?: string; + browser?: string; + device?: string; + $os?: string; + $browser?: string; + $device?: string; + browser_user_agent?: string; + browser_version?: string; + os_version?: string; + referrer?: string; + referring_domain?: string; + referrer_current?: string; + referring_domain_current?: string; + release_channel?: "stable" | "dev" | "ptb" | "canary"; + client_build_number?: number; + client_event_source?: any; + client_version?: string; + system_locale?: string; + }; + intents?: bigint; // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt + presence?: ActivitySchema; + compress?: boolean; + large_threshold?: number; + shard?: [bigint, bigint]; + guild_subscriptions?: boolean; + capabilities?: number; + client_state?: { + guild_hashes?: any; + highest_last_message_id?: string; + read_state_version?: number; + user_guild_settings_version?: number; + user_settings_version?: number; + }; + v?: number; +} diff --git a/util/src/schemas/InviteCreateSchema.ts b/util/src/schemas/InviteCreateSchema.ts new file mode 100644 index 00000000..7f6af338 --- /dev/null +++ b/util/src/schemas/InviteCreateSchema.ts @@ -0,0 +1,12 @@ + +export interface InviteCreateSchema { + target_user_id?: string; + target_type?: string; + validate?: string; // ? what is this + max_age?: number; + max_uses?: number; + temporary?: boolean; + unique?: boolean; + target_user?: string; + target_user_type?: number; +} diff --git a/util/src/schemas/LazyRequestSchema.ts b/util/src/schemas/LazyRequestSchema.ts new file mode 100644 index 00000000..1fe658bb --- /dev/null +++ b/util/src/schemas/LazyRequestSchema.ts @@ -0,0 +1,19 @@ +export interface LazyRequest { + guild_id: string; + channels?: Record; + activities?: boolean; + threads?: boolean; + typing?: true; + members?: any[]; + thread_member_lists?: any[]; +} + +export const LazyRequest = { + guild_id: String, + $activities: Boolean, + $channels: Object, + $typing: Boolean, + $threads: Boolean, + $members: [] as any[], + $thread_member_lists: [] as any[], +}; diff --git a/util/src/schemas/LoginSchema.ts b/util/src/schemas/LoginSchema.ts new file mode 100644 index 00000000..358019a8 --- /dev/null +++ b/util/src/schemas/LoginSchema.ts @@ -0,0 +1,9 @@ + +export interface LoginSchema { + login: string; + password: string; + undelete?: boolean; + captcha_key?: string; + login_source?: string; + gift_code_sku_id?: string; +} diff --git a/util/src/schemas/MemberChangeSchema.ts b/util/src/schemas/MemberChangeSchema.ts new file mode 100644 index 00000000..a75c0ea0 --- /dev/null +++ b/util/src/schemas/MemberChangeSchema.ts @@ -0,0 +1,4 @@ + +export interface MemberChangeSchema { + roles?: string[]; +} diff --git a/util/src/schemas/MemberNickChangeSchema.ts b/util/src/schemas/MemberNickChangeSchema.ts new file mode 100644 index 00000000..e6a6a007 --- /dev/null +++ b/util/src/schemas/MemberNickChangeSchema.ts @@ -0,0 +1,4 @@ + +export interface MemberNickChangeSchema { + nick: string; +} diff --git a/util/src/schemas/MessageAcknowledgeSchema.ts b/util/src/schemas/MessageAcknowledgeSchema.ts new file mode 100644 index 00000000..3f4eb2b6 --- /dev/null +++ b/util/src/schemas/MessageAcknowledgeSchema.ts @@ -0,0 +1,8 @@ +// TODO: public read receipts & privacy scoping +// TODO: send read state event to all channel members +// TODO: advance-only notification cursor + +export interface MessageAcknowledgeSchema { + manual?: boolean; + mention_count?: number; +} diff --git a/util/src/schemas/MessageCreateSchema.ts b/util/src/schemas/MessageCreateSchema.ts new file mode 100644 index 00000000..7b1cc7b9 --- /dev/null +++ b/util/src/schemas/MessageCreateSchema.ts @@ -0,0 +1,34 @@ +import { Embed } from "@fosscord/util"; + + +export interface MessageCreateSchema { + type?: number; + content?: string; + nonce?: string; + channel_id?: string; + tts?: boolean; + flags?: string; + embeds?: Embed[]; + embed?: Embed; + // TODO: ^ embed is deprecated in favor of embeds (https://discord.com/developers/docs/resources/channel#message-object) + allowed_mentions?: { + parse?: string[]; + roles?: string[]; + users?: string[]; + replied_user?: boolean; + }; + message_reference?: { + message_id: string; + channel_id: string; + guild_id?: string; + fail_if_not_exists?: boolean; + }; + payload_json?: string; + file?: any; + /** + TODO: we should create an interface for attachments + TODO: OpenWAAO<-->attachment-style metadata conversion + **/ + attachments?: any[]; + sticker_ids?: string[]; +} diff --git a/util/src/schemas/MfaCodesSchema.ts b/util/src/schemas/MfaCodesSchema.ts new file mode 100644 index 00000000..53230841 --- /dev/null +++ b/util/src/schemas/MfaCodesSchema.ts @@ -0,0 +1,5 @@ + +export interface MfaCodesSchema { + password: string; + regenerate?: boolean; +} diff --git a/util/src/schemas/ModifyGuildStickerSchema.ts b/util/src/schemas/ModifyGuildStickerSchema.ts new file mode 100644 index 00000000..6f24e4ce --- /dev/null +++ b/util/src/schemas/ModifyGuildStickerSchema.ts @@ -0,0 +1,16 @@ + +export interface ModifyGuildStickerSchema { + /** + * @minLength 2 + * @maxLength 30 + */ + name: string; + /** + * @maxLength 100 + */ + description?: string; + /** + * @maxLength 200 + */ + tags: string; +} diff --git a/util/src/schemas/PruneSchema.ts b/util/src/schemas/PruneSchema.ts new file mode 100644 index 00000000..eebac763 --- /dev/null +++ b/util/src/schemas/PruneSchema.ts @@ -0,0 +1,7 @@ + +export interface PruneSchema { + /** + * @min 0 + */ + days: number; +} diff --git a/util/src/schemas/PurgeSchema.ts b/util/src/schemas/PurgeSchema.ts new file mode 100644 index 00000000..0eeef6f2 --- /dev/null +++ b/util/src/schemas/PurgeSchema.ts @@ -0,0 +1,5 @@ + +export interface PurgeSchema { + before: string; + after: string; +} diff --git a/util/src/schemas/RegisterSchema.ts b/util/src/schemas/RegisterSchema.ts new file mode 100644 index 00000000..e53330d2 --- /dev/null +++ b/util/src/schemas/RegisterSchema.ts @@ -0,0 +1,27 @@ + +export interface RegisterSchema { + /** + * @minLength 2 + * @maxLength 32 + */ + username: string; + /** + * @minLength 1 + * @maxLength 72 + */ + password?: string; + consent: boolean; + /** + * @TJS-format email + */ + email?: string; + fingerprint?: string; + invite?: string; + /** + * @TJS-type string + */ + date_of_birth?: Date; // "2000-04-03" + gift_code_sku_id?: string; + captcha_key?: string; + promotional_email_opt_in?: boolean; +} diff --git a/util/src/schemas/RelationshipPostSchema.ts b/util/src/schemas/RelationshipPostSchema.ts new file mode 100644 index 00000000..40093700 --- /dev/null +++ b/util/src/schemas/RelationshipPostSchema.ts @@ -0,0 +1,5 @@ + +export interface RelationshipPostSchema { + discriminator: string; + username: string; +} diff --git a/util/src/schemas/RelationshipPutSchema.ts b/util/src/schemas/RelationshipPutSchema.ts new file mode 100644 index 00000000..f46966e0 --- /dev/null +++ b/util/src/schemas/RelationshipPutSchema.ts @@ -0,0 +1,6 @@ +import { RelationshipType } from "@fosscord/util"; + + +export interface RelationshipPutSchema { + type?: RelationshipType; +} diff --git a/util/src/schemas/RoleModifySchema.ts b/util/src/schemas/RoleModifySchema.ts new file mode 100644 index 00000000..d08a5022 --- /dev/null +++ b/util/src/schemas/RoleModifySchema.ts @@ -0,0 +1,11 @@ + +export interface RoleModifySchema { + name?: string; + permissions?: string; + color?: number; + hoist?: boolean; // whether the role should be displayed separately in the sidebar + mentionable?: boolean; // whether the role should be mentionable + position?: number; + icon?: string; + unicode_emoji?: string; +} diff --git a/util/src/schemas/TemplateCreateSchema.ts b/util/src/schemas/TemplateCreateSchema.ts new file mode 100644 index 00000000..72c19f68 --- /dev/null +++ b/util/src/schemas/TemplateCreateSchema.ts @@ -0,0 +1,5 @@ + +export interface TemplateCreateSchema { + name: string; + description?: string; +} diff --git a/util/src/schemas/TemplateModifySchema.ts b/util/src/schemas/TemplateModifySchema.ts new file mode 100644 index 00000000..2231a1d2 --- /dev/null +++ b/util/src/schemas/TemplateModifySchema.ts @@ -0,0 +1,5 @@ + +export interface TemplateModifySchema { + name: string; + description?: string; +} diff --git a/util/src/schemas/TotpDisableSchema.ts b/util/src/schemas/TotpDisableSchema.ts new file mode 100644 index 00000000..b73db64e --- /dev/null +++ b/util/src/schemas/TotpDisableSchema.ts @@ -0,0 +1,4 @@ + +export interface TotpDisableSchema { + code: string; +} diff --git a/util/src/schemas/TotpEnableSchema.ts b/util/src/schemas/TotpEnableSchema.ts new file mode 100644 index 00000000..44d9ebac --- /dev/null +++ b/util/src/schemas/TotpEnableSchema.ts @@ -0,0 +1,6 @@ + +export interface TotpEnableSchema { + password: string; + code?: string; + secret?: string; +} diff --git a/util/src/schemas/TotpSchema.ts b/util/src/schemas/TotpSchema.ts new file mode 100644 index 00000000..fe54735e --- /dev/null +++ b/util/src/schemas/TotpSchema.ts @@ -0,0 +1,7 @@ + +export interface TotpSchema { + code: string; + ticket: string; + gift_code_sku_id?: string | null; + login_source?: string | null; +} diff --git a/util/src/schemas/UserModifySchema.ts b/util/src/schemas/UserModifySchema.ts new file mode 100644 index 00000000..659f5841 --- /dev/null +++ b/util/src/schemas/UserModifySchema.ts @@ -0,0 +1,19 @@ + +export interface UserModifySchema { + /** + * @minLength 1 + * @maxLength 100 + */ + username?: string; + discriminator?: string; + avatar?: string | null; + /** + * @maxLength 1024 + */ + bio?: string; + accent_color?: number; + banner?: string | null; + password?: string; + new_password?: string; + code?: string; +} diff --git a/util/src/schemas/UserSettingsSchema.ts b/util/src/schemas/UserSettingsSchema.ts new file mode 100644 index 00000000..b497dff2 --- /dev/null +++ b/util/src/schemas/UserSettingsSchema.ts @@ -0,0 +1,4 @@ +import { UserSettings } from "@fosscord/util"; + + +export interface UserSettingsSchema extends Partial { } diff --git a/util/src/schemas/VanityUrlSchema.ts b/util/src/schemas/VanityUrlSchema.ts new file mode 100644 index 00000000..de32695a --- /dev/null +++ b/util/src/schemas/VanityUrlSchema.ts @@ -0,0 +1,8 @@ + +export interface VanityUrlSchema { + /** + * @minLength 1 + * @maxLength 20 + */ + code?: string; +} diff --git a/util/src/schemas/VoiceStateUpdateSchema.ts b/util/src/schemas/VoiceStateUpdateSchema.ts new file mode 100644 index 00000000..02bb141b --- /dev/null +++ b/util/src/schemas/VoiceStateUpdateSchema.ts @@ -0,0 +1,18 @@ +export const VoiceStateUpdateSchema = { + $guild_id: String, + $channel_id: String, + self_mute: Boolean, + self_deaf: Boolean, + self_video: Boolean, +}; + +//TODO need more testing when community guild and voice stage channel are working +export interface VoiceStateUpdateSchema { + channel_id: string; + guild_id?: string; + suppress?: boolean; + request_to_speak_timestamp?: Date; + self_mute?: boolean; + self_deaf?: boolean; + self_video?: boolean; +} \ No newline at end of file diff --git a/util/src/schemas/WebhookCreateSchema.ts b/util/src/schemas/WebhookCreateSchema.ts new file mode 100644 index 00000000..12ab1869 --- /dev/null +++ b/util/src/schemas/WebhookCreateSchema.ts @@ -0,0 +1,8 @@ +// TODO: webhooks +export interface WebhookCreateSchema { + /** + * @maxLength 80 + */ + name: string; + avatar?: string; +} diff --git a/util/src/schemas/WidgetModifySchema.ts b/util/src/schemas/WidgetModifySchema.ts new file mode 100644 index 00000000..390efc30 --- /dev/null +++ b/util/src/schemas/WidgetModifySchema.ts @@ -0,0 +1,5 @@ + +export interface WidgetModifySchema { + enabled: boolean; // whether the widget is enabled + channel_id: string; // the widget channel id +} diff --git a/util/src/schemas/index.ts b/util/src/schemas/index.ts new file mode 100644 index 00000000..f54ae840 --- /dev/null +++ b/util/src/schemas/index.ts @@ -0,0 +1,41 @@ +export * from "./ActivitySchema"; +export * from "./BanCreateSchema"; +export * from "./BanModeratorSchema"; +export * from "./BanRegistrySchema"; +export * from "./BulkDeleteSchema"; +export * from "./ChannelModifySchema"; +export * from "./ChannelPermissionOverwriteSchema"; +export * from "./DmChannelCreateSchema"; +export * from "./EmojiCreateSchema"; +export * from "./EmojiModifySchema"; +export * from "./GuildCreateSchema"; +export * from "./GuildTemplateCreateSchema"; +export * from "./GuildUpdateSchema"; +export * from "./GuildUpdateWelcomeScreenSchema"; +export * from "./IdentifySchema"; +export * from "./InviteCreateSchema"; +export * from "./LazyRequestSchema"; +export * from "./LoginSchema"; +export * from "./MemberChangeSchema"; +export * from "./MemberNickChangeSchema"; +export * from "./MessageAcknowledgeSchema"; +export * from "./MessageCreateSchema"; +export * from "./MfaCodesSchema"; +export * from "./ModifyGuildStickerSchema"; +export * from "./PruneSchema"; +export * from "./PurgeSchema"; +export * from "./RegisterSchema"; +export * from "./RelationshipPostSchema"; +export * from "./RelationshipPutSchema"; +export * from "./RoleModifySchema"; +export * from "./TemplateCreateSchema"; +export * from "./TemplateModifySchema"; +export * from "./TotpDisableSchema"; +export * from "./TotpEnableSchema"; +export * from "./TotpSchema"; +export * from "./UserModifySchema"; +export * from "./UserSettingsSchema"; +export * from "./VanityUrlSchema"; +export * from "./VoiceStateUpdateSchema"; +export * from "./WebhookCreateSchema"; +export * from "./WidgetModifySchema"; diff --git a/util/src/util/Config.ts b/util/src/util/Config.ts index 0b55ca4b..e0fb2a81 100644 --- a/util/src/util/Config.ts +++ b/util/src/util/Config.ts @@ -60,8 +60,11 @@ function applyConfig(val: ConfigValue) { pair.value = obj; return pair.save(); } - if(process.env.CONFIG_PATH) + if(process.env.CONFIG_PATH) { + if(/--debug|--inspect/.test(process.execArgv.join(' '))) + console.log(`Writing config: ${process.env.CONFIG_PATH}`) fs.writeFileSync(overridePath, JSON.stringify(val, null, 4)); + } return apply(val); } -- cgit 1.5.1 From 6d3706c2c8efda6e170eac2081a60f41a09bb41f Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 13 Aug 2022 22:14:22 +0200 Subject: Fix rebase conflicts --- api/src/routes/applications/#id/bot/index.ts | 83 --- api/src/routes/applications/#id/index.ts | 30 - api/src/routes/applications/#id/skus.ts | 11 - gateway/src/opcodes/Identify.ts | 298 -------- src/api/routes/applications/#id/bot/index.ts | 83 +++ src/api/routes/applications/#id/index.ts | 30 + src/api/routes/applications/#id/skus.ts | 11 + src/gateway/opcodes/Identify.ts | 4 +- .../mariadb/1660130586602-updated-applications.ts | 185 +++++ .../mariadb/1660131942703-apps_nullable_team.ts | 18 + .../mariadb/1660258393551-CodeCleanup3.ts | 232 ------ .../postgres/1660130561959-updated-applications.ts | 182 +++++ .../sqlite/1660130536131-updated-applications.ts | 829 +++++++++++++++++++++ .../mariadb/1660130586602-updated-applications.ts | 185 ----- .../mariadb/1660131942703-apps_nullable_team.ts | 18 - .../mariadb/1660416072362-InvitersAreDeletable.ts | 56 -- .../postgres/1660130561959-updated-applications.ts | 182 ----- .../postgres/1660416055566-InvitersAreDeletable.ts | 26 - .../sqlite/1660130536131-updated-applications.ts | 829 --------------------- .../sqlite/1660416010862-InvitersAreDeletable.ts | 246 ------ 20 files changed, 1340 insertions(+), 2198 deletions(-) delete mode 100644 api/src/routes/applications/#id/bot/index.ts delete mode 100644 api/src/routes/applications/#id/index.ts delete mode 100644 api/src/routes/applications/#id/skus.ts delete mode 100644 gateway/src/opcodes/Identify.ts create mode 100644 src/api/routes/applications/#id/bot/index.ts create mode 100644 src/api/routes/applications/#id/index.ts create mode 100644 src/api/routes/applications/#id/skus.ts create mode 100644 src/util/migrations/mariadb/1660130586602-updated-applications.ts create mode 100644 src/util/migrations/mariadb/1660131942703-apps_nullable_team.ts delete mode 100644 src/util/migrations/mariadb/1660258393551-CodeCleanup3.ts create mode 100644 src/util/migrations/postgres/1660130561959-updated-applications.ts create mode 100644 src/util/migrations/sqlite/1660130536131-updated-applications.ts delete mode 100644 util/src/migrations/mariadb/1660130586602-updated-applications.ts delete mode 100644 util/src/migrations/mariadb/1660131942703-apps_nullable_team.ts delete mode 100644 util/src/migrations/mariadb/1660416072362-InvitersAreDeletable.ts delete mode 100644 util/src/migrations/postgres/1660130561959-updated-applications.ts delete mode 100644 util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts delete mode 100644 util/src/migrations/sqlite/1660130536131-updated-applications.ts delete mode 100644 util/src/migrations/sqlite/1660416010862-InvitersAreDeletable.ts (limited to 'gateway/src/opcodes/Identify.ts') diff --git a/api/src/routes/applications/#id/bot/index.ts b/api/src/routes/applications/#id/bot/index.ts deleted file mode 100644 index 5cae5215..00000000 --- a/api/src/routes/applications/#id/bot/index.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { Request, Response, Router } from "express"; -import { route } from "@fosscord/api"; -import { Application, Config, FieldErrors, generateToken, OrmUtils, Snowflake, trimSpecial, User, handleFile } from "@fosscord/util"; -import { HTTPError } from "lambert-server"; -import { verifyToken } from "node-2fa"; - -const router: Router = Router(); - -router.post("/", route({}), async (req: Request, res: Response) => { - const app = await Application.findOne({where: {id: req.params.id}}); - if(!app) return res.status(404); - const username = trimSpecial(app.name); - const discriminator = await User.generateDiscriminator(username); - if (!discriminator) { - // We've failed to generate a valid and unused discriminator - throw FieldErrors({ - username: { - code: "USERNAME_TOO_MANY_USERS", - message: req?.t("auth:register.USERNAME_TOO_MANY_USERS"), - }, - }); - } - - const user = OrmUtils.mergeDeep(new User(), { - created_at: new Date(), - username: username, - discriminator, - id: app.id, - bot: true, - system: false, - premium_since: null, - desktop: false, - mobile: false, - premium: false, - premium_type: 0, - bio: app.description, - mfa_enabled: true, - totp_secret: "", - totp_backup_codes: [], - verified: true, - disabled: false, - deleted: false, - email: null, - rights: Config.get().register.defaultRights, - nsfw_allowed: true, - public_flags: "0", - flags: "0", - data: { - hash: null, - valid_tokens_since: new Date(), - }, - settings: {}, - extended_settings: {}, - fingerprints: [], - notes: {}, - }); - await user.save(); - app.bot = user; - await app.save(); - res.send().status(204) -}); - -router.post("/reset", route({}), async (req: Request, res: Response) => { - let bot = await User.findOne({where: {id: req.params.id}}); - let owner = await User.findOne({where: {id: req.user_id}}); - if(!bot) return res.status(404); - if(owner?.totp_secret && (!req.body.code || verifyToken(owner.totp_secret, req.body.code))) { - throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008); - } - bot.data = { hash: undefined, valid_tokens_since: new Date() }; - await bot.save(); - let token = await generateToken(bot.id); - res.json({token}).status(200); -}); - -router.patch("/", route({}), async (req: Request, res: Response) => { - if (req.body.avatar) req.body.avatar = await handleFile(`/avatars/${req.params.id}`, req.body.avatar as string); - let app = OrmUtils.mergeDeep(await User.findOne({where: {id: req.params.id}}), req.body); - await app.save(); - res.json(app).status(200); -}); - -export default router; \ No newline at end of file diff --git a/api/src/routes/applications/#id/index.ts b/api/src/routes/applications/#id/index.ts deleted file mode 100644 index 0aced582..00000000 --- a/api/src/routes/applications/#id/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Request, Response, Router } from "express"; -import { route } from "@fosscord/api"; -import { Application, OrmUtils, Team, trimSpecial, User } from "@fosscord/util"; - -const router: Router = Router(); - -router.get("/", route({}), async (req: Request, res: Response) => { - let results = await Application.findOne({where: {id: req.params.id}, relations: ["owner", "bot"] }); - res.json(results).status(200); -}); - -router.patch("/", route({}), async (req: Request, res: Response) => { - delete req.body.icon; - let app = OrmUtils.mergeDeep(await Application.findOne({where: {id: req.params.id}, relations: ["owner", "bot"]}), req.body); - if(app.bot) { - app.bot.bio = req.body.description - app.bot?.save(); - } - if(req.body.tags) app.tags = req.body.tags; - await app.save(); - res.json(app).status(200); -}); - -router.post("/delete", route({}), async (req: Request, res: Response) => { - await Application.delete(req.params.id); - res.send().status(200); -}); - - -export default router; \ No newline at end of file diff --git a/api/src/routes/applications/#id/skus.ts b/api/src/routes/applications/#id/skus.ts deleted file mode 100644 index 5b667f36..00000000 --- a/api/src/routes/applications/#id/skus.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Request, Response, Router } from "express"; -import { route } from "@fosscord/api"; -import { Application, OrmUtils, Team, trimSpecial, User } from "@fosscord/util"; - -const router: Router = Router(); - -router.get("/", route({}), async (req: Request, res: Response) => { - res.json([]).status(200); -}); - -export default router; \ No newline at end of file diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts deleted file mode 100644 index e62c1570..00000000 --- a/gateway/src/opcodes/Identify.ts +++ /dev/null @@ -1,298 +0,0 @@ -import { WebSocket, Payload } from "@fosscord/gateway"; -import { - checkToken, - Intents, - Member, - ReadyEventData, - User, - Session, - EVENTEnum, - Config, - PublicMember, - PublicUser, - PrivateUserProjection, - ReadState, - Application, - emitEvent, - SessionsReplace, - PrivateSessionProjection, - MemberPrivateProjection, - PresenceUpdateEvent, - UserSettings, - IdentifySchema, -} from "@fosscord/util"; -import { Send } from "../util/Send"; -import { CLOSECODES, OPCODES } from "../util/Constants"; -import { genSessionId } from "../util/SessionUtils"; -import { setupListener } from "../listener/listener"; -// import experiments from "./experiments.json"; -const experiments: any = []; -import { check } from "./instanceOf"; -import { Recipient } from "@fosscord/util"; -import { OrmUtils } from "@fosscord/util"; - -// TODO: user sharding -// TODO: check privileged intents, if defined in the config -// TODO: check if already identified - -export async function onIdentify(this: WebSocket, data: Payload) { - clearTimeout(this.readyTimeout); - check.call(this, IdentifySchema, data.d); - - const identify: IdentifySchema = data.d; - - try { - const { jwtSecret } = Config.get().security; - var { decoded } = await checkToken(identify.token, jwtSecret); // will throw an error if invalid - } catch (error) { - console.error("invalid token", error); - return this.close(CLOSECODES.Authentication_failed); - } - this.user_id = decoded.id; - - const session_id = genSessionId(); - this.session_id = session_id; //Set the session of the WebSocket object - - const [user, read_states, members, recipients, session, application] = - await Promise.all([ - User.findOneOrFail({ - where: { id: this.user_id }, - relations: ["relationships", "relationships.to", "settings"], - select: [...PrivateUserProjection, "relationships"], - }), - ReadState.find({ where: { user_id: this.user_id } }), - Member.find({ - where: { id: this.user_id }, - select: MemberPrivateProjection, - relations: [ - "guild", - "guild.channels", - "guild.emojis", - "guild.emojis.user", - "guild.roles", - "guild.stickers", - "user", - "roles", - ], - }), - Recipient.find({ - where: { user_id: this.user_id, closed: false }, - relations: [ - "channel", - "channel.recipients", - "channel.recipients.user", - ], - // TODO: public user selection - }), - // save the session and delete it when the websocket is closed - await OrmUtils.mergeDeep(new Session(), { - user_id: this.user_id, - session_id: session_id, - // TODO: check if status is only one of: online, dnd, offline, idle - status: identify.presence?.status || "offline", //does the session always start as online? - client_info: { - //TODO read from identity - client: "desktop", - os: identify.properties?.os, - version: 0, - }, - activities: [], - }).save(), - Application.findOne({ where: { id: this.user_id } }), - ]); - - if (!user) return this.close(CLOSECODES.Authentication_failed); - if (!user.settings) { //settings may not exist after updating... - user.settings = new UserSettings(); - user.settings.id = user.id; - await user.settings.save(); - } - - if (!identify.intents) identify.intents = BigInt("0x6ffffffff"); - this.intents = new Intents(identify.intents); - if (identify.shard) { - this.shard_id = identify.shard[0]; - this.shard_count = identify.shard[1]; - if ( - this.shard_count == null || - this.shard_id == null || - this.shard_id >= this.shard_count || - this.shard_id < 0 || - this.shard_count <= 0 - ) { - console.log(identify.shard); - return this.close(CLOSECODES.Invalid_shard); - } - } - let users: PublicUser[] = []; - - const merged_members = members.map((x: Member) => { - return [ - { - ...x, - roles: x.roles.map((x) => x.id), - settings: undefined, - guild: undefined, - }, - ]; - }) as PublicMember[][]; - let guilds = members.map((x) => ({ ...x.guild, joined_at: x.joined_at })); - - // @ts-ignore - guilds = guilds.map((guild) => { - if (user.bot) { - setTimeout(() => { - Send(this, { - op: OPCODES.Dispatch, - t: EVENTEnum.GuildCreate, - s: this.sequence++, - d: guild, - }); - }, 500); - return { id: guild.id, unavailable: true }; - } - - return guild; - }); - - const user_guild_settings_entries = members.map((x) => x.settings); - - const channels = recipients.map((x) => { - // @ts-ignore - x.channel.recipients = x.channel.recipients?.map((x) => x.user); - //TODO is this needed? check if users in group dm that are not friends are sent in the READY event - users = users.concat(x.channel.recipients as unknown as User[]); - if (x.channel.isDm()) { - x.channel.recipients = x.channel.recipients!.filter( - (x) => x.id !== this.user_id - ); - } - return x.channel; - }); - - for (let relation of user.relationships) { - const related_user = relation.to; - const public_related_user = { - username: related_user.username, - discriminator: related_user.discriminator, - id: related_user.id, - public_flags: related_user.public_flags, - avatar: related_user.avatar, - bot: related_user.bot, - bio: related_user.bio, - premium_since: user.premium_since - }; - users.push(public_related_user); - } - - setImmediate(async () => { - // run in seperate "promise context" because ready payload is not dependent on those events - emitEvent({ - event: "SESSIONS_REPLACE", - user_id: this.user_id, - data: await Session.find({ - where: { user_id: this.user_id }, - select: PrivateSessionProjection, - }), - } as SessionsReplace); - emitEvent({ - event: "PRESENCE_UPDATE", - user_id: this.user_id, - data: { - user: await User.getPublicUser(this.user_id), - activities: session.activities, - client_status: session?.client_info, - status: session.status, - }, - } as PresenceUpdateEvent); - }); - - read_states.forEach((s: any) => { - s.id = s.channel_id; - delete s.user_id; - delete s.channel_id; - }); - - const privateUser = { - avatar: user.avatar, - mobile: user.mobile, - desktop: user.desktop, - discriminator: user.discriminator, - email: user.email, - flags: user.flags, - id: user.id, - mfa_enabled: user.mfa_enabled, - nsfw_allowed: user.nsfw_allowed, - phone: user.phone, - premium: user.premium, - premium_type: user.premium_type, - public_flags: user.public_flags, - username: user.username, - verified: user.verified, - bot: user.bot, - accent_color: user.accent_color || 0, - banner: user.banner, - bio: user.bio, - premium_since: user.premium_since - }; - - const d: ReadyEventData = { - v: 8, - application: {id: application?.id??'', flags: application?.flags??0}, //TODO: check this code! - user: privateUser, - user_settings: user.settings, - // @ts-ignore - guilds: guilds.map((x) => { - // @ts-ignore - x.guild_hashes = {}; // @ts-ignore - x.guild_scheduled_events = []; // @ts-ignore - x.threads = []; - return x; - }), - guild_experiments: [], // TODO - geo_ordered_rtc_regions: [], // TODO - relationships: user.relationships.map((x) => x.toPublicRelationship()), - read_state: { - entries: read_states, - partial: false, - version: 304128, - }, - user_guild_settings: { - entries: user_guild_settings_entries, - partial: false, // TODO partial - version: 642, - }, - private_channels: channels, - session_id: session_id, - analytics_token: "", // TODO - connected_accounts: [], // TODO - consents: { - personalization: { - consented: false, // TODO - }, - }, - country_code: user.settings.locale, - friend_suggestion_count: 0, // TODO - // @ts-ignore - experiments: experiments, // TODO - guild_join_requests: [], // TODO what is this? - users: users.filter((x) => x).unique(), - merged_members: merged_members, - // shard // TODO: only for user sharding - }; - - // TODO: send real proper data structure - await Send(this, { - op: OPCODES.Dispatch, - t: EVENTEnum.Ready, - s: this.sequence++, - d, - }); - - //TODO send READY_SUPPLEMENTAL - //TODO send GUILD_MEMBER_LIST_UPDATE - //TODO send SESSIONS_REPLACE - //TODO send VOICE_STATE_UPDATE to let the client know if another device is already connected to a voice channel - - await setupListener.call(this); -} diff --git a/src/api/routes/applications/#id/bot/index.ts b/src/api/routes/applications/#id/bot/index.ts new file mode 100644 index 00000000..5cae5215 --- /dev/null +++ b/src/api/routes/applications/#id/bot/index.ts @@ -0,0 +1,83 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; +import { Application, Config, FieldErrors, generateToken, OrmUtils, Snowflake, trimSpecial, User, handleFile } from "@fosscord/util"; +import { HTTPError } from "lambert-server"; +import { verifyToken } from "node-2fa"; + +const router: Router = Router(); + +router.post("/", route({}), async (req: Request, res: Response) => { + const app = await Application.findOne({where: {id: req.params.id}}); + if(!app) return res.status(404); + const username = trimSpecial(app.name); + const discriminator = await User.generateDiscriminator(username); + if (!discriminator) { + // We've failed to generate a valid and unused discriminator + throw FieldErrors({ + username: { + code: "USERNAME_TOO_MANY_USERS", + message: req?.t("auth:register.USERNAME_TOO_MANY_USERS"), + }, + }); + } + + const user = OrmUtils.mergeDeep(new User(), { + created_at: new Date(), + username: username, + discriminator, + id: app.id, + bot: true, + system: false, + premium_since: null, + desktop: false, + mobile: false, + premium: false, + premium_type: 0, + bio: app.description, + mfa_enabled: true, + totp_secret: "", + totp_backup_codes: [], + verified: true, + disabled: false, + deleted: false, + email: null, + rights: Config.get().register.defaultRights, + nsfw_allowed: true, + public_flags: "0", + flags: "0", + data: { + hash: null, + valid_tokens_since: new Date(), + }, + settings: {}, + extended_settings: {}, + fingerprints: [], + notes: {}, + }); + await user.save(); + app.bot = user; + await app.save(); + res.send().status(204) +}); + +router.post("/reset", route({}), async (req: Request, res: Response) => { + let bot = await User.findOne({where: {id: req.params.id}}); + let owner = await User.findOne({where: {id: req.user_id}}); + if(!bot) return res.status(404); + if(owner?.totp_secret && (!req.body.code || verifyToken(owner.totp_secret, req.body.code))) { + throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008); + } + bot.data = { hash: undefined, valid_tokens_since: new Date() }; + await bot.save(); + let token = await generateToken(bot.id); + res.json({token}).status(200); +}); + +router.patch("/", route({}), async (req: Request, res: Response) => { + if (req.body.avatar) req.body.avatar = await handleFile(`/avatars/${req.params.id}`, req.body.avatar as string); + let app = OrmUtils.mergeDeep(await User.findOne({where: {id: req.params.id}}), req.body); + await app.save(); + res.json(app).status(200); +}); + +export default router; \ No newline at end of file diff --git a/src/api/routes/applications/#id/index.ts b/src/api/routes/applications/#id/index.ts new file mode 100644 index 00000000..0aced582 --- /dev/null +++ b/src/api/routes/applications/#id/index.ts @@ -0,0 +1,30 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; +import { Application, OrmUtils, Team, trimSpecial, User } from "@fosscord/util"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + let results = await Application.findOne({where: {id: req.params.id}, relations: ["owner", "bot"] }); + res.json(results).status(200); +}); + +router.patch("/", route({}), async (req: Request, res: Response) => { + delete req.body.icon; + let app = OrmUtils.mergeDeep(await Application.findOne({where: {id: req.params.id}, relations: ["owner", "bot"]}), req.body); + if(app.bot) { + app.bot.bio = req.body.description + app.bot?.save(); + } + if(req.body.tags) app.tags = req.body.tags; + await app.save(); + res.json(app).status(200); +}); + +router.post("/delete", route({}), async (req: Request, res: Response) => { + await Application.delete(req.params.id); + res.send().status(200); +}); + + +export default router; \ No newline at end of file diff --git a/src/api/routes/applications/#id/skus.ts b/src/api/routes/applications/#id/skus.ts new file mode 100644 index 00000000..5b667f36 --- /dev/null +++ b/src/api/routes/applications/#id/skus.ts @@ -0,0 +1,11 @@ +import { Request, Response, Router } from "express"; +import { route } from "@fosscord/api"; +import { Application, OrmUtils, Team, trimSpecial, User } from "@fosscord/util"; + +const router: Router = Router(); + +router.get("/", route({}), async (req: Request, res: Response) => { + res.json([]).status(200); +}); + +export default router; \ No newline at end of file diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts index 4f17ab70..d5dae7b0 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts @@ -108,7 +108,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { await user.settings.save(); } - if (!identify.intents) identify.intents = "0x6ffffffff" + if (!identify.intents) identify.intents = "30064771071"; this.intents = new Intents(identify.intents); if (identify.shard) { this.shard_id = identify.shard[0]; @@ -238,7 +238,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { const d: ReadyEventData = { v: 8, - application: {id: application?.id??'', flags: application?.flags??''}, //TODO: check this code! + application: {id: application?.id??'', flags: application?.flags??0}, //TODO: check this code! user: privateUser, user_settings: user.settings, // @ts-ignore diff --git a/src/util/migrations/mariadb/1660130586602-updated-applications.ts b/src/util/migrations/mariadb/1660130586602-updated-applications.ts new file mode 100644 index 00000000..ec574416 --- /dev/null +++ b/src/util/migrations/mariadb/1660130586602-updated-applications.ts @@ -0,0 +1,185 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class updatedApplications1660130586602 implements MigrationInterface { + name = 'updatedApplications1660130586602' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_e5bf78cdbbe9ba91062d74c5aba\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`rpc_origins\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`primary_sku_id\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`slug\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`guild_id\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`type\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`hook\` tinyint NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`redirect_uris\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`rpc_application_state\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`store_application_state\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`verification_state\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`interactions_endpoint_url\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`integration_public\` tinyint NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`integration_require_code_grant\` tinyint NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`discoverability_state\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`discovery_eligibility_flags\` int NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`tags\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`install_params\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`bot_user_id\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD UNIQUE INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\` (\`bot_user_id\`) + `); + await queryRunner.query(` + ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`flags\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`flags\` int NOT NULL + `); + await queryRunner.query(` + CREATE UNIQUE INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` (\`bot_user_id\`) + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD CONSTRAINT \`FK_2ce5a55796fe4c2f77ece57a647\` FOREIGN KEY (\`bot_user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_2ce5a55796fe4c2f77ece57a647\` + `); + await queryRunner.query(` + DROP INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`flags\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`flags\` varchar(255) NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`bot_user_id\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`install_params\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`tags\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`discovery_eligibility_flags\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`discoverability_state\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`integration_require_code_grant\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`integration_public\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`interactions_endpoint_url\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`verification_state\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`store_application_state\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`rpc_application_state\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`redirect_uris\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`hook\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` DROP COLUMN \`type\` + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`guild_id\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`slug\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`primary_sku_id\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD \`rpc_origins\` text NULL + `); + await queryRunner.query(` + ALTER TABLE \`applications\` + ADD CONSTRAINT \`FK_e5bf78cdbbe9ba91062d74c5aba\` FOREIGN KEY (\`guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + +} diff --git a/src/util/migrations/mariadb/1660131942703-apps_nullable_team.ts b/src/util/migrations/mariadb/1660131942703-apps_nullable_team.ts new file mode 100644 index 00000000..ac445772 --- /dev/null +++ b/src/util/migrations/mariadb/1660131942703-apps_nullable_team.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class appsNullableTeam1660131942703 implements MigrationInterface { + name = 'appsNullableTeam1660131942703' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + DROP INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + CREATE UNIQUE INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` (\`bot_user_id\`) + `); + } + +} diff --git a/src/util/migrations/mariadb/1660258393551-CodeCleanup3.ts b/src/util/migrations/mariadb/1660258393551-CodeCleanup3.ts deleted file mode 100644 index 87d075e4..00000000 --- a/src/util/migrations/mariadb/1660258393551-CodeCleanup3.ts +++ /dev/null @@ -1,232 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class CodeCleanup31660258393551 implements MigrationInterface { - name = 'CodeCleanup31660258393551' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_2ce5a55796fe4c2f77ece57a647\` - `); - await queryRunner.query(` - DROP INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` - `); - await queryRunner.query(` - CREATE TABLE \`user_settings\` ( - \`id\` varchar(255) NOT NULL, - \`afk_timeout\` int NULL, - \`allow_accessibility_detection\` tinyint NULL, - \`animate_emoji\` tinyint NULL, - \`animate_stickers\` int NULL, - \`contact_sync_enabled\` tinyint NULL, - \`convert_emoticons\` tinyint NULL, - \`custom_status\` text NULL, - \`default_guilds_restricted\` tinyint NULL, - \`detect_platform_accounts\` tinyint NULL, - \`developer_mode\` tinyint NULL, - \`disable_games_tab\` tinyint NULL, - \`enable_tts_command\` tinyint NULL, - \`explicit_content_filter\` int NULL, - \`friend_source_flags\` text NULL, - \`gateway_connected\` tinyint NULL, - \`gif_auto_play\` tinyint NULL, - \`guild_folders\` text NULL, - \`guild_positions\` text NULL, - \`inline_attachment_media\` tinyint NULL, - \`inline_embed_media\` tinyint NULL, - \`locale\` varchar(255) NULL, - \`message_display_compact\` tinyint NULL, - \`native_phone_integration_enabled\` tinyint NULL, - \`render_embeds\` tinyint NULL, - \`render_reactions\` tinyint NULL, - \`restricted_guilds\` text NULL, - \`show_current_game\` tinyint NULL, - \`status\` varchar(255) NULL, - \`stream_notifications_enabled\` tinyint NULL, - \`theme\` varchar(255) NULL, - \`timezone_offset\` int NULL, - PRIMARY KEY (\`id\`) - ) ENGINE = InnoDB - `); - await queryRunner.query(` - ALTER TABLE \`users\` DROP COLUMN \`settings\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`type\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`hook\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`redirect_uris\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`rpc_application_state\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`store_application_state\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`verification_state\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`interactions_endpoint_url\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`integration_public\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`integration_require_code_grant\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`discoverability_state\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`discovery_eligibility_flags\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`tags\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`install_params\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`bot_user_id\` - `); - await queryRunner.query(` - ALTER TABLE \`guilds\` - ADD \`premium_progress_bar_enabled\` tinyint NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`rpc_origins\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`primary_sku_id\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`slug\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`guild_id\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NOT NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`flags\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`flags\` varchar(255) NOT NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD CONSTRAINT \`FK_e5bf78cdbbe9ba91062d74c5aba\` FOREIGN KEY (\`guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_e5bf78cdbbe9ba91062d74c5aba\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`flags\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`flags\` int NOT NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`guild_id\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`slug\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`primary_sku_id\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`rpc_origins\` - `); - await queryRunner.query(` - ALTER TABLE \`guilds\` DROP COLUMN \`premium_progress_bar_enabled\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`bot_user_id\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`install_params\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`tags\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`discovery_eligibility_flags\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`discoverability_state\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`integration_require_code_grant\` tinyint NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`integration_public\` tinyint NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`interactions_endpoint_url\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`verification_state\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`store_application_state\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`rpc_application_state\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`redirect_uris\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`hook\` tinyint NOT NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`type\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`users\` - ADD \`settings\` text NOT NULL - `); - await queryRunner.query(` - DROP TABLE \`user_settings\` - `); - await queryRunner.query(` - CREATE UNIQUE INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` (\`bot_user_id\`) - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD CONSTRAINT \`FK_2ce5a55796fe4c2f77ece57a647\` FOREIGN KEY (\`bot_user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION - `); - } - -} diff --git a/src/util/migrations/postgres/1660130561959-updated-applications.ts b/src/util/migrations/postgres/1660130561959-updated-applications.ts new file mode 100644 index 00000000..8fab54c7 --- /dev/null +++ b/src/util/migrations/postgres/1660130561959-updated-applications.ts @@ -0,0 +1,182 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class updatedApplications1660130561959 implements MigrationInterface { + name = 'updatedApplications1660130561959' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE "applications" DROP CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "rpc_origins" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "primary_sku_id" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "slug" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "guild_id" + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "type" text + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "hook" boolean NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "redirect_uris" text + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "rpc_application_state" integer + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "store_application_state" integer + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "verification_state" integer + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "interactions_endpoint_url" character varying + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "integration_public" boolean + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "integration_require_code_grant" boolean + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "discoverability_state" integer + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "discovery_eligibility_flags" integer + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "tags" text + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "install_params" text + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "bot_user_id" character varying + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD CONSTRAINT "UQ_2ce5a55796fe4c2f77ece57a647" UNIQUE ("bot_user_id") + `); + await queryRunner.query(` + ALTER TABLE "applications" + ALTER COLUMN "description" DROP NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "flags" + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "flags" integer NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD CONSTRAINT "FK_2ce5a55796fe4c2f77ece57a647" FOREIGN KEY ("bot_user_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE "applications" DROP CONSTRAINT "FK_2ce5a55796fe4c2f77ece57a647" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "flags" + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "flags" character varying NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "applications" + ALTER COLUMN "description" + SET NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP CONSTRAINT "UQ_2ce5a55796fe4c2f77ece57a647" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "bot_user_id" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "install_params" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "tags" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "discovery_eligibility_flags" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "discoverability_state" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "integration_require_code_grant" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "integration_public" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "interactions_endpoint_url" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "verification_state" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "store_application_state" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "rpc_application_state" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "redirect_uris" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "hook" + `); + await queryRunner.query(` + ALTER TABLE "applications" DROP COLUMN "type" + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "guild_id" character varying + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "slug" character varying + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "primary_sku_id" character varying + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD "rpc_origins" text + `); + await queryRunner.query(` + ALTER TABLE "applications" + ADD CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba" FOREIGN KEY ("guild_id") REFERENCES "guilds"("id") ON DELETE NO ACTION ON UPDATE NO ACTION + `); + } + +} diff --git a/src/util/migrations/sqlite/1660130536131-updated-applications.ts b/src/util/migrations/sqlite/1660130536131-updated-applications.ts new file mode 100644 index 00000000..b8cbcc33 --- /dev/null +++ b/src/util/migrations/sqlite/1660130536131-updated-applications.ts @@ -0,0 +1,829 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class updatedApplications1660130536131 implements MigrationInterface { + name = 'updatedApplications1660130536131' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + CREATE TABLE "temporary_applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar NOT NULL, + "rpc_origins" text, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "primary_sku_id" varchar, + "slug" varchar, + "cover_image" varchar, + "flags" varchar NOT NULL, + "owner_id" varchar, + "team_id" varchar, + "guild_id" varchar, + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_applications"( + "id", + "name", + "icon", + "description", + "rpc_origins", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "primary_sku_id", + "slug", + "cover_image", + "flags", + "owner_id", + "team_id", + "guild_id" + ) + SELECT "id", + "name", + "icon", + "description", + "rpc_origins", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "primary_sku_id", + "slug", + "cover_image", + "flags", + "owner_id", + "team_id", + "guild_id" + FROM "applications" + `); + await queryRunner.query(` + DROP TABLE "applications" + `); + await queryRunner.query(` + ALTER TABLE "temporary_applications" + RENAME TO "applications" + `); + await queryRunner.query(` + CREATE TABLE "temporary_applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar NOT NULL, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "cover_image" varchar, + "flags" varchar NOT NULL, + "owner_id" varchar, + "team_id" varchar, + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_applications"( + "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id" + ) + SELECT "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id" + FROM "applications" + `); + await queryRunner.query(` + DROP TABLE "applications" + `); + await queryRunner.query(` + ALTER TABLE "temporary_applications" + RENAME TO "applications" + `); + await queryRunner.query(` + CREATE TABLE "temporary_applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar NOT NULL, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "cover_image" varchar, + "flags" varchar NOT NULL, + "owner_id" varchar, + "team_id" varchar, + "type" text, + "hook" boolean NOT NULL, + "redirect_uris" text, + "rpc_application_state" integer, + "store_application_state" integer, + "verification_state" integer, + "interactions_endpoint_url" varchar, + "integration_public" boolean, + "integration_require_code_grant" boolean, + "discoverability_state" integer, + "discovery_eligibility_flags" integer, + "tags" text, + "install_params" text, + "bot_user_id" varchar, + CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_applications"( + "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id" + ) + SELECT "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id" + FROM "applications" + `); + await queryRunner.query(` + DROP TABLE "applications" + `); + await queryRunner.query(` + ALTER TABLE "temporary_applications" + RENAME TO "applications" + `); + await queryRunner.query(` + CREATE TABLE "temporary_applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "cover_image" varchar, + "flags" integer NOT NULL, + "owner_id" varchar, + "team_id" varchar, + "type" text, + "hook" boolean NOT NULL, + "redirect_uris" text, + "rpc_application_state" integer, + "store_application_state" integer, + "verification_state" integer, + "interactions_endpoint_url" varchar, + "integration_public" boolean, + "integration_require_code_grant" boolean, + "discoverability_state" integer, + "discovery_eligibility_flags" integer, + "tags" text, + "install_params" text, + "bot_user_id" varchar, + CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_applications"( + "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id", + "type", + "hook", + "redirect_uris", + "rpc_application_state", + "store_application_state", + "verification_state", + "interactions_endpoint_url", + "integration_public", + "integration_require_code_grant", + "discoverability_state", + "discovery_eligibility_flags", + "tags", + "install_params", + "bot_user_id" + ) + SELECT "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id", + "type", + "hook", + "redirect_uris", + "rpc_application_state", + "store_application_state", + "verification_state", + "interactions_endpoint_url", + "integration_public", + "integration_require_code_grant", + "discoverability_state", + "discovery_eligibility_flags", + "tags", + "install_params", + "bot_user_id" + FROM "applications" + `); + await queryRunner.query(` + DROP TABLE "applications" + `); + await queryRunner.query(` + ALTER TABLE "temporary_applications" + RENAME TO "applications" + `); + await queryRunner.query(` + CREATE TABLE "temporary_applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "cover_image" varchar, + "flags" integer NOT NULL, + "owner_id" varchar, + "team_id" varchar, + "type" text, + "hook" boolean NOT NULL, + "redirect_uris" text, + "rpc_application_state" integer, + "store_application_state" integer, + "verification_state" integer, + "interactions_endpoint_url" varchar, + "integration_public" boolean, + "integration_require_code_grant" boolean, + "discoverability_state" integer, + "discovery_eligibility_flags" integer, + "tags" text, + "install_params" text, + "bot_user_id" varchar, + CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_2ce5a55796fe4c2f77ece57a647" FOREIGN KEY ("bot_user_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_applications"( + "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id", + "type", + "hook", + "redirect_uris", + "rpc_application_state", + "store_application_state", + "verification_state", + "interactions_endpoint_url", + "integration_public", + "integration_require_code_grant", + "discoverability_state", + "discovery_eligibility_flags", + "tags", + "install_params", + "bot_user_id" + ) + SELECT "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id", + "type", + "hook", + "redirect_uris", + "rpc_application_state", + "store_application_state", + "verification_state", + "interactions_endpoint_url", + "integration_public", + "integration_require_code_grant", + "discoverability_state", + "discovery_eligibility_flags", + "tags", + "install_params", + "bot_user_id" + FROM "applications" + `); + await queryRunner.query(` + DROP TABLE "applications" + `); + await queryRunner.query(` + ALTER TABLE "temporary_applications" + RENAME TO "applications" + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE "applications" + RENAME TO "temporary_applications" + `); + await queryRunner.query(` + CREATE TABLE "applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "cover_image" varchar, + "flags" integer NOT NULL, + "owner_id" varchar, + "team_id" varchar, + "type" text, + "hook" boolean NOT NULL, + "redirect_uris" text, + "rpc_application_state" integer, + "store_application_state" integer, + "verification_state" integer, + "interactions_endpoint_url" varchar, + "integration_public" boolean, + "integration_require_code_grant" boolean, + "discoverability_state" integer, + "discovery_eligibility_flags" integer, + "tags" text, + "install_params" text, + "bot_user_id" varchar, + CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "applications"( + "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id", + "type", + "hook", + "redirect_uris", + "rpc_application_state", + "store_application_state", + "verification_state", + "interactions_endpoint_url", + "integration_public", + "integration_require_code_grant", + "discoverability_state", + "discovery_eligibility_flags", + "tags", + "install_params", + "bot_user_id" + ) + SELECT "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id", + "type", + "hook", + "redirect_uris", + "rpc_application_state", + "store_application_state", + "verification_state", + "interactions_endpoint_url", + "integration_public", + "integration_require_code_grant", + "discoverability_state", + "discovery_eligibility_flags", + "tags", + "install_params", + "bot_user_id" + FROM "temporary_applications" + `); + await queryRunner.query(` + DROP TABLE "temporary_applications" + `); + await queryRunner.query(` + ALTER TABLE "applications" + RENAME TO "temporary_applications" + `); + await queryRunner.query(` + CREATE TABLE "applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar NOT NULL, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "cover_image" varchar, + "flags" varchar NOT NULL, + "owner_id" varchar, + "team_id" varchar, + "type" text, + "hook" boolean NOT NULL, + "redirect_uris" text, + "rpc_application_state" integer, + "store_application_state" integer, + "verification_state" integer, + "interactions_endpoint_url" varchar, + "integration_public" boolean, + "integration_require_code_grant" boolean, + "discoverability_state" integer, + "discovery_eligibility_flags" integer, + "tags" text, + "install_params" text, + "bot_user_id" varchar, + CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "applications"( + "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id", + "type", + "hook", + "redirect_uris", + "rpc_application_state", + "store_application_state", + "verification_state", + "interactions_endpoint_url", + "integration_public", + "integration_require_code_grant", + "discoverability_state", + "discovery_eligibility_flags", + "tags", + "install_params", + "bot_user_id" + ) + SELECT "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id", + "type", + "hook", + "redirect_uris", + "rpc_application_state", + "store_application_state", + "verification_state", + "interactions_endpoint_url", + "integration_public", + "integration_require_code_grant", + "discoverability_state", + "discovery_eligibility_flags", + "tags", + "install_params", + "bot_user_id" + FROM "temporary_applications" + `); + await queryRunner.query(` + DROP TABLE "temporary_applications" + `); + await queryRunner.query(` + ALTER TABLE "applications" + RENAME TO "temporary_applications" + `); + await queryRunner.query(` + CREATE TABLE "applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar NOT NULL, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "cover_image" varchar, + "flags" varchar NOT NULL, + "owner_id" varchar, + "team_id" varchar, + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "applications"( + "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id" + ) + SELECT "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id" + FROM "temporary_applications" + `); + await queryRunner.query(` + DROP TABLE "temporary_applications" + `); + await queryRunner.query(` + ALTER TABLE "applications" + RENAME TO "temporary_applications" + `); + await queryRunner.query(` + CREATE TABLE "applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar NOT NULL, + "rpc_origins" text, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "primary_sku_id" varchar, + "slug" varchar, + "cover_image" varchar, + "flags" varchar NOT NULL, + "owner_id" varchar, + "team_id" varchar, + "guild_id" varchar, + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "applications"( + "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id" + ) + SELECT "id", + "name", + "icon", + "description", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "cover_image", + "flags", + "owner_id", + "team_id" + FROM "temporary_applications" + `); + await queryRunner.query(` + DROP TABLE "temporary_applications" + `); + await queryRunner.query(` + ALTER TABLE "applications" + RENAME TO "temporary_applications" + `); + await queryRunner.query(` + CREATE TABLE "applications" ( + "id" varchar PRIMARY KEY NOT NULL, + "name" varchar NOT NULL, + "icon" varchar, + "description" varchar NOT NULL, + "rpc_origins" text, + "bot_public" boolean NOT NULL, + "bot_require_code_grant" boolean NOT NULL, + "terms_of_service_url" varchar, + "privacy_policy_url" varchar, + "summary" varchar, + "verify_key" varchar NOT NULL, + "primary_sku_id" varchar, + "slug" varchar, + "cover_image" varchar, + "flags" varchar NOT NULL, + "owner_id" varchar, + "team_id" varchar, + "guild_id" varchar, + CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "applications"( + "id", + "name", + "icon", + "description", + "rpc_origins", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "primary_sku_id", + "slug", + "cover_image", + "flags", + "owner_id", + "team_id", + "guild_id" + ) + SELECT "id", + "name", + "icon", + "description", + "rpc_origins", + "bot_public", + "bot_require_code_grant", + "terms_of_service_url", + "privacy_policy_url", + "summary", + "verify_key", + "primary_sku_id", + "slug", + "cover_image", + "flags", + "owner_id", + "team_id", + "guild_id" + FROM "temporary_applications" + `); + await queryRunner.query(` + DROP TABLE "temporary_applications" + `); + } + +} diff --git a/util/src/migrations/mariadb/1660130586602-updated-applications.ts b/util/src/migrations/mariadb/1660130586602-updated-applications.ts deleted file mode 100644 index ec574416..00000000 --- a/util/src/migrations/mariadb/1660130586602-updated-applications.ts +++ /dev/null @@ -1,185 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class updatedApplications1660130586602 implements MigrationInterface { - name = 'updatedApplications1660130586602' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_e5bf78cdbbe9ba91062d74c5aba\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`rpc_origins\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`primary_sku_id\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`slug\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`guild_id\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`type\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`hook\` tinyint NOT NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`redirect_uris\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`rpc_application_state\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`store_application_state\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`verification_state\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`interactions_endpoint_url\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`integration_public\` tinyint NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`integration_require_code_grant\` tinyint NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`discoverability_state\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`discovery_eligibility_flags\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`tags\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`install_params\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`bot_user_id\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD UNIQUE INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\` (\`bot_user_id\`) - `); - await queryRunner.query(` - ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`flags\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`flags\` int NOT NULL - `); - await queryRunner.query(` - CREATE UNIQUE INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` (\`bot_user_id\`) - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD CONSTRAINT \`FK_2ce5a55796fe4c2f77ece57a647\` FOREIGN KEY (\`bot_user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_2ce5a55796fe4c2f77ece57a647\` - `); - await queryRunner.query(` - DROP INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`flags\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`flags\` varchar(255) NOT NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NOT NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`bot_user_id\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`install_params\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`tags\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`discovery_eligibility_flags\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`discoverability_state\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`integration_require_code_grant\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`integration_public\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`interactions_endpoint_url\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`verification_state\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`store_application_state\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`rpc_application_state\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`redirect_uris\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`hook\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` DROP COLUMN \`type\` - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`guild_id\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`slug\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`primary_sku_id\` varchar(255) NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD \`rpc_origins\` text NULL - `); - await queryRunner.query(` - ALTER TABLE \`applications\` - ADD CONSTRAINT \`FK_e5bf78cdbbe9ba91062d74c5aba\` FOREIGN KEY (\`guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION - `); - } - -} diff --git a/util/src/migrations/mariadb/1660131942703-apps_nullable_team.ts b/util/src/migrations/mariadb/1660131942703-apps_nullable_team.ts deleted file mode 100644 index ac445772..00000000 --- a/util/src/migrations/mariadb/1660131942703-apps_nullable_team.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class appsNullableTeam1660131942703 implements MigrationInterface { - name = 'appsNullableTeam1660131942703' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - DROP INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - CREATE UNIQUE INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` (\`bot_user_id\`) - `); - } - -} diff --git a/util/src/migrations/mariadb/1660416072362-InvitersAreDeletable.ts b/util/src/migrations/mariadb/1660416072362-InvitersAreDeletable.ts deleted file mode 100644 index 8374eafb..00000000 --- a/util/src/migrations/mariadb/1660416072362-InvitersAreDeletable.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class InvitersAreDeletable1660416072362 implements MigrationInterface { - name = 'InvitersAreDeletable1660416072362' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\` - `); - await queryRunner.query(` - DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\` - `); - await queryRunner.query(` - CREATE TABLE \`plugin_config\` ( - \`key\` varchar(255) NOT NULL, - \`value\` text NULL, - PRIMARY KEY (\`key\`) - ) ENGINE = InnoDB - `); - await queryRunner.query(` - ALTER TABLE \`channels\` - ADD \`flags\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`channels\` - ADD \`default_thread_rate_limit_per_user\` int NULL - `); - await queryRunner.query(` - ALTER TABLE \`invites\` - ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\` - `); - await queryRunner.query(` - ALTER TABLE \`channels\` DROP COLUMN \`default_thread_rate_limit_per_user\` - `); - await queryRunner.query(` - ALTER TABLE \`channels\` DROP COLUMN \`flags\` - `); - await queryRunner.query(` - DROP TABLE \`plugin_config\` - `); - await queryRunner.query(` - CREATE UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`) - `); - await queryRunner.query(` - ALTER TABLE \`invites\` - ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION - `); - } - -} diff --git a/util/src/migrations/postgres/1660130561959-updated-applications.ts b/util/src/migrations/postgres/1660130561959-updated-applications.ts deleted file mode 100644 index 8fab54c7..00000000 --- a/util/src/migrations/postgres/1660130561959-updated-applications.ts +++ /dev/null @@ -1,182 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class updatedApplications1660130561959 implements MigrationInterface { - name = 'updatedApplications1660130561959' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE "applications" DROP CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "rpc_origins" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "primary_sku_id" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "slug" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "guild_id" - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "type" text - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "hook" boolean NOT NULL - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "redirect_uris" text - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "rpc_application_state" integer - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "store_application_state" integer - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "verification_state" integer - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "interactions_endpoint_url" character varying - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "integration_public" boolean - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "integration_require_code_grant" boolean - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "discoverability_state" integer - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "discovery_eligibility_flags" integer - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "tags" text - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "install_params" text - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "bot_user_id" character varying - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD CONSTRAINT "UQ_2ce5a55796fe4c2f77ece57a647" UNIQUE ("bot_user_id") - `); - await queryRunner.query(` - ALTER TABLE "applications" - ALTER COLUMN "description" DROP NOT NULL - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "flags" - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "flags" integer NOT NULL - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD CONSTRAINT "FK_2ce5a55796fe4c2f77ece57a647" FOREIGN KEY ("bot_user_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE "applications" DROP CONSTRAINT "FK_2ce5a55796fe4c2f77ece57a647" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "flags" - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "flags" character varying NOT NULL - `); - await queryRunner.query(` - ALTER TABLE "applications" - ALTER COLUMN "description" - SET NOT NULL - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP CONSTRAINT "UQ_2ce5a55796fe4c2f77ece57a647" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "bot_user_id" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "install_params" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "tags" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "discovery_eligibility_flags" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "discoverability_state" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "integration_require_code_grant" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "integration_public" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "interactions_endpoint_url" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "verification_state" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "store_application_state" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "rpc_application_state" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "redirect_uris" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "hook" - `); - await queryRunner.query(` - ALTER TABLE "applications" DROP COLUMN "type" - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "guild_id" character varying - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "slug" character varying - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "primary_sku_id" character varying - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD "rpc_origins" text - `); - await queryRunner.query(` - ALTER TABLE "applications" - ADD CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba" FOREIGN KEY ("guild_id") REFERENCES "guilds"("id") ON DELETE NO ACTION ON UPDATE NO ACTION - `); - } - -} diff --git a/util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts b/util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts deleted file mode 100644 index e6101318..00000000 --- a/util/src/migrations/postgres/1660416055566-InvitersAreDeletable.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class InvitersAreDeletable1660416055566 implements MigrationInterface { - name = 'InvitersAreDeletable1660416055566' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE "invites" DROP CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" - `); - await queryRunner.query(` - ALTER TABLE "invites" - ADD CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" FOREIGN KEY ("inviter_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE "invites" DROP CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" - `); - await queryRunner.query(` - ALTER TABLE "invites" - ADD CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" FOREIGN KEY ("inviter_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION - `); - } - -} diff --git a/util/src/migrations/sqlite/1660130536131-updated-applications.ts b/util/src/migrations/sqlite/1660130536131-updated-applications.ts deleted file mode 100644 index b8cbcc33..00000000 --- a/util/src/migrations/sqlite/1660130536131-updated-applications.ts +++ /dev/null @@ -1,829 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class updatedApplications1660130536131 implements MigrationInterface { - name = 'updatedApplications1660130536131' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - CREATE TABLE "temporary_applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar NOT NULL, - "rpc_origins" text, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "primary_sku_id" varchar, - "slug" varchar, - "cover_image" varchar, - "flags" varchar NOT NULL, - "owner_id" varchar, - "team_id" varchar, - "guild_id" varchar, - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "temporary_applications"( - "id", - "name", - "icon", - "description", - "rpc_origins", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "primary_sku_id", - "slug", - "cover_image", - "flags", - "owner_id", - "team_id", - "guild_id" - ) - SELECT "id", - "name", - "icon", - "description", - "rpc_origins", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "primary_sku_id", - "slug", - "cover_image", - "flags", - "owner_id", - "team_id", - "guild_id" - FROM "applications" - `); - await queryRunner.query(` - DROP TABLE "applications" - `); - await queryRunner.query(` - ALTER TABLE "temporary_applications" - RENAME TO "applications" - `); - await queryRunner.query(` - CREATE TABLE "temporary_applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar NOT NULL, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "cover_image" varchar, - "flags" varchar NOT NULL, - "owner_id" varchar, - "team_id" varchar, - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "temporary_applications"( - "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id" - ) - SELECT "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id" - FROM "applications" - `); - await queryRunner.query(` - DROP TABLE "applications" - `); - await queryRunner.query(` - ALTER TABLE "temporary_applications" - RENAME TO "applications" - `); - await queryRunner.query(` - CREATE TABLE "temporary_applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar NOT NULL, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "cover_image" varchar, - "flags" varchar NOT NULL, - "owner_id" varchar, - "team_id" varchar, - "type" text, - "hook" boolean NOT NULL, - "redirect_uris" text, - "rpc_application_state" integer, - "store_application_state" integer, - "verification_state" integer, - "interactions_endpoint_url" varchar, - "integration_public" boolean, - "integration_require_code_grant" boolean, - "discoverability_state" integer, - "discovery_eligibility_flags" integer, - "tags" text, - "install_params" text, - "bot_user_id" varchar, - CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "temporary_applications"( - "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id" - ) - SELECT "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id" - FROM "applications" - `); - await queryRunner.query(` - DROP TABLE "applications" - `); - await queryRunner.query(` - ALTER TABLE "temporary_applications" - RENAME TO "applications" - `); - await queryRunner.query(` - CREATE TABLE "temporary_applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "cover_image" varchar, - "flags" integer NOT NULL, - "owner_id" varchar, - "team_id" varchar, - "type" text, - "hook" boolean NOT NULL, - "redirect_uris" text, - "rpc_application_state" integer, - "store_application_state" integer, - "verification_state" integer, - "interactions_endpoint_url" varchar, - "integration_public" boolean, - "integration_require_code_grant" boolean, - "discoverability_state" integer, - "discovery_eligibility_flags" integer, - "tags" text, - "install_params" text, - "bot_user_id" varchar, - CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "temporary_applications"( - "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id", - "type", - "hook", - "redirect_uris", - "rpc_application_state", - "store_application_state", - "verification_state", - "interactions_endpoint_url", - "integration_public", - "integration_require_code_grant", - "discoverability_state", - "discovery_eligibility_flags", - "tags", - "install_params", - "bot_user_id" - ) - SELECT "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id", - "type", - "hook", - "redirect_uris", - "rpc_application_state", - "store_application_state", - "verification_state", - "interactions_endpoint_url", - "integration_public", - "integration_require_code_grant", - "discoverability_state", - "discovery_eligibility_flags", - "tags", - "install_params", - "bot_user_id" - FROM "applications" - `); - await queryRunner.query(` - DROP TABLE "applications" - `); - await queryRunner.query(` - ALTER TABLE "temporary_applications" - RENAME TO "applications" - `); - await queryRunner.query(` - CREATE TABLE "temporary_applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "cover_image" varchar, - "flags" integer NOT NULL, - "owner_id" varchar, - "team_id" varchar, - "type" text, - "hook" boolean NOT NULL, - "redirect_uris" text, - "rpc_application_state" integer, - "store_application_state" integer, - "verification_state" integer, - "interactions_endpoint_url" varchar, - "integration_public" boolean, - "integration_require_code_grant" boolean, - "discoverability_state" integer, - "discovery_eligibility_flags" integer, - "tags" text, - "install_params" text, - "bot_user_id" varchar, - CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT "FK_2ce5a55796fe4c2f77ece57a647" FOREIGN KEY ("bot_user_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "temporary_applications"( - "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id", - "type", - "hook", - "redirect_uris", - "rpc_application_state", - "store_application_state", - "verification_state", - "interactions_endpoint_url", - "integration_public", - "integration_require_code_grant", - "discoverability_state", - "discovery_eligibility_flags", - "tags", - "install_params", - "bot_user_id" - ) - SELECT "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id", - "type", - "hook", - "redirect_uris", - "rpc_application_state", - "store_application_state", - "verification_state", - "interactions_endpoint_url", - "integration_public", - "integration_require_code_grant", - "discoverability_state", - "discovery_eligibility_flags", - "tags", - "install_params", - "bot_user_id" - FROM "applications" - `); - await queryRunner.query(` - DROP TABLE "applications" - `); - await queryRunner.query(` - ALTER TABLE "temporary_applications" - RENAME TO "applications" - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE "applications" - RENAME TO "temporary_applications" - `); - await queryRunner.query(` - CREATE TABLE "applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "cover_image" varchar, - "flags" integer NOT NULL, - "owner_id" varchar, - "team_id" varchar, - "type" text, - "hook" boolean NOT NULL, - "redirect_uris" text, - "rpc_application_state" integer, - "store_application_state" integer, - "verification_state" integer, - "interactions_endpoint_url" varchar, - "integration_public" boolean, - "integration_require_code_grant" boolean, - "discoverability_state" integer, - "discovery_eligibility_flags" integer, - "tags" text, - "install_params" text, - "bot_user_id" varchar, - CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "applications"( - "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id", - "type", - "hook", - "redirect_uris", - "rpc_application_state", - "store_application_state", - "verification_state", - "interactions_endpoint_url", - "integration_public", - "integration_require_code_grant", - "discoverability_state", - "discovery_eligibility_flags", - "tags", - "install_params", - "bot_user_id" - ) - SELECT "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id", - "type", - "hook", - "redirect_uris", - "rpc_application_state", - "store_application_state", - "verification_state", - "interactions_endpoint_url", - "integration_public", - "integration_require_code_grant", - "discoverability_state", - "discovery_eligibility_flags", - "tags", - "install_params", - "bot_user_id" - FROM "temporary_applications" - `); - await queryRunner.query(` - DROP TABLE "temporary_applications" - `); - await queryRunner.query(` - ALTER TABLE "applications" - RENAME TO "temporary_applications" - `); - await queryRunner.query(` - CREATE TABLE "applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar NOT NULL, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "cover_image" varchar, - "flags" varchar NOT NULL, - "owner_id" varchar, - "team_id" varchar, - "type" text, - "hook" boolean NOT NULL, - "redirect_uris" text, - "rpc_application_state" integer, - "store_application_state" integer, - "verification_state" integer, - "interactions_endpoint_url" varchar, - "integration_public" boolean, - "integration_require_code_grant" boolean, - "discoverability_state" integer, - "discovery_eligibility_flags" integer, - "tags" text, - "install_params" text, - "bot_user_id" varchar, - CONSTRAINT "UQ_b7f6e13565e920916d902e1f431" UNIQUE ("bot_user_id"), - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "applications"( - "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id", - "type", - "hook", - "redirect_uris", - "rpc_application_state", - "store_application_state", - "verification_state", - "interactions_endpoint_url", - "integration_public", - "integration_require_code_grant", - "discoverability_state", - "discovery_eligibility_flags", - "tags", - "install_params", - "bot_user_id" - ) - SELECT "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id", - "type", - "hook", - "redirect_uris", - "rpc_application_state", - "store_application_state", - "verification_state", - "interactions_endpoint_url", - "integration_public", - "integration_require_code_grant", - "discoverability_state", - "discovery_eligibility_flags", - "tags", - "install_params", - "bot_user_id" - FROM "temporary_applications" - `); - await queryRunner.query(` - DROP TABLE "temporary_applications" - `); - await queryRunner.query(` - ALTER TABLE "applications" - RENAME TO "temporary_applications" - `); - await queryRunner.query(` - CREATE TABLE "applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar NOT NULL, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "cover_image" varchar, - "flags" varchar NOT NULL, - "owner_id" varchar, - "team_id" varchar, - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "applications"( - "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id" - ) - SELECT "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id" - FROM "temporary_applications" - `); - await queryRunner.query(` - DROP TABLE "temporary_applications" - `); - await queryRunner.query(` - ALTER TABLE "applications" - RENAME TO "temporary_applications" - `); - await queryRunner.query(` - CREATE TABLE "applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar NOT NULL, - "rpc_origins" text, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "primary_sku_id" varchar, - "slug" varchar, - "cover_image" varchar, - "flags" varchar NOT NULL, - "owner_id" varchar, - "team_id" varchar, - "guild_id" varchar, - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "applications"( - "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id" - ) - SELECT "id", - "name", - "icon", - "description", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "cover_image", - "flags", - "owner_id", - "team_id" - FROM "temporary_applications" - `); - await queryRunner.query(` - DROP TABLE "temporary_applications" - `); - await queryRunner.query(` - ALTER TABLE "applications" - RENAME TO "temporary_applications" - `); - await queryRunner.query(` - CREATE TABLE "applications" ( - "id" varchar PRIMARY KEY NOT NULL, - "name" varchar NOT NULL, - "icon" varchar, - "description" varchar NOT NULL, - "rpc_origins" text, - "bot_public" boolean NOT NULL, - "bot_require_code_grant" boolean NOT NULL, - "terms_of_service_url" varchar, - "privacy_policy_url" varchar, - "summary" varchar, - "verify_key" varchar NOT NULL, - "primary_sku_id" varchar, - "slug" varchar, - "cover_image" varchar, - "flags" varchar NOT NULL, - "owner_id" varchar, - "team_id" varchar, - "guild_id" varchar, - CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT "FK_a36ed02953077f408d0f3ebc424" FOREIGN KEY ("team_id") REFERENCES "teams" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "applications"( - "id", - "name", - "icon", - "description", - "rpc_origins", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "primary_sku_id", - "slug", - "cover_image", - "flags", - "owner_id", - "team_id", - "guild_id" - ) - SELECT "id", - "name", - "icon", - "description", - "rpc_origins", - "bot_public", - "bot_require_code_grant", - "terms_of_service_url", - "privacy_policy_url", - "summary", - "verify_key", - "primary_sku_id", - "slug", - "cover_image", - "flags", - "owner_id", - "team_id", - "guild_id" - FROM "temporary_applications" - `); - await queryRunner.query(` - DROP TABLE "temporary_applications" - `); - } - -} diff --git a/util/src/migrations/sqlite/1660416010862-InvitersAreDeletable.ts b/util/src/migrations/sqlite/1660416010862-InvitersAreDeletable.ts deleted file mode 100644 index 9b29e119..00000000 --- a/util/src/migrations/sqlite/1660416010862-InvitersAreDeletable.ts +++ /dev/null @@ -1,246 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class InvitersAreDeletable1660416010862 implements MigrationInterface { - name = 'InvitersAreDeletable1660416010862' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - CREATE TABLE "temporary_invites" ( - "code" varchar PRIMARY KEY NOT NULL, - "temporary" boolean NOT NULL, - "uses" integer NOT NULL, - "max_uses" integer NOT NULL, - "max_age" integer NOT NULL, - "created_at" datetime NOT NULL, - "expires_at" datetime NOT NULL, - "guild_id" varchar, - "channel_id" varchar, - "inviter_id" varchar, - "target_user_id" varchar, - "target_user_type" integer, - "vanity_url" boolean, - CONSTRAINT "FK_11a0d394f8fc649c19ce5f16b59" FOREIGN KEY ("target_user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_6a15b051fe5050aa00a4b9ff0f6" FOREIGN KEY ("channel_id") REFERENCES "channels" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_3f4939aa1461e8af57fea3fb05d" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "temporary_invites"( - "code", - "temporary", - "uses", - "max_uses", - "max_age", - "created_at", - "expires_at", - "guild_id", - "channel_id", - "inviter_id", - "target_user_id", - "target_user_type", - "vanity_url" - ) - SELECT "code", - "temporary", - "uses", - "max_uses", - "max_age", - "created_at", - "expires_at", - "guild_id", - "channel_id", - "inviter_id", - "target_user_id", - "target_user_type", - "vanity_url" - FROM "invites" - `); - await queryRunner.query(` - DROP TABLE "invites" - `); - await queryRunner.query(` - ALTER TABLE "temporary_invites" - RENAME TO "invites" - `); - await queryRunner.query(` - CREATE TABLE "temporary_invites" ( - "code" varchar PRIMARY KEY NOT NULL, - "temporary" boolean NOT NULL, - "uses" integer NOT NULL, - "max_uses" integer NOT NULL, - "max_age" integer NOT NULL, - "created_at" datetime NOT NULL, - "expires_at" datetime NOT NULL, - "guild_id" varchar, - "channel_id" varchar, - "inviter_id" varchar, - "target_user_id" varchar, - "target_user_type" integer, - "vanity_url" boolean, - CONSTRAINT "FK_11a0d394f8fc649c19ce5f16b59" FOREIGN KEY ("target_user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_6a15b051fe5050aa00a4b9ff0f6" FOREIGN KEY ("channel_id") REFERENCES "channels" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_3f4939aa1461e8af57fea3fb05d" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" FOREIGN KEY ("inviter_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "temporary_invites"( - "code", - "temporary", - "uses", - "max_uses", - "max_age", - "created_at", - "expires_at", - "guild_id", - "channel_id", - "inviter_id", - "target_user_id", - "target_user_type", - "vanity_url" - ) - SELECT "code", - "temporary", - "uses", - "max_uses", - "max_age", - "created_at", - "expires_at", - "guild_id", - "channel_id", - "inviter_id", - "target_user_id", - "target_user_type", - "vanity_url" - FROM "invites" - `); - await queryRunner.query(` - DROP TABLE "invites" - `); - await queryRunner.query(` - ALTER TABLE "temporary_invites" - RENAME TO "invites" - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - ALTER TABLE "invites" - RENAME TO "temporary_invites" - `); - await queryRunner.query(` - CREATE TABLE "invites" ( - "code" varchar PRIMARY KEY NOT NULL, - "temporary" boolean NOT NULL, - "uses" integer NOT NULL, - "max_uses" integer NOT NULL, - "max_age" integer NOT NULL, - "created_at" datetime NOT NULL, - "expires_at" datetime NOT NULL, - "guild_id" varchar, - "channel_id" varchar, - "inviter_id" varchar, - "target_user_id" varchar, - "target_user_type" integer, - "vanity_url" boolean, - CONSTRAINT "FK_11a0d394f8fc649c19ce5f16b59" FOREIGN KEY ("target_user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_6a15b051fe5050aa00a4b9ff0f6" FOREIGN KEY ("channel_id") REFERENCES "channels" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_3f4939aa1461e8af57fea3fb05d" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "invites"( - "code", - "temporary", - "uses", - "max_uses", - "max_age", - "created_at", - "expires_at", - "guild_id", - "channel_id", - "inviter_id", - "target_user_id", - "target_user_type", - "vanity_url" - ) - SELECT "code", - "temporary", - "uses", - "max_uses", - "max_age", - "created_at", - "expires_at", - "guild_id", - "channel_id", - "inviter_id", - "target_user_id", - "target_user_type", - "vanity_url" - FROM "temporary_invites" - `); - await queryRunner.query(` - DROP TABLE "temporary_invites" - `); - await queryRunner.query(` - ALTER TABLE "invites" - RENAME TO "temporary_invites" - `); - await queryRunner.query(` - CREATE TABLE "invites" ( - "code" varchar PRIMARY KEY NOT NULL, - "temporary" boolean NOT NULL, - "uses" integer NOT NULL, - "max_uses" integer NOT NULL, - "max_age" integer NOT NULL, - "created_at" datetime NOT NULL, - "expires_at" datetime NOT NULL, - "guild_id" varchar, - "channel_id" varchar, - "inviter_id" varchar, - "target_user_id" varchar, - "target_user_type" integer, - "vanity_url" boolean, - CONSTRAINT "FK_11a0d394f8fc649c19ce5f16b59" FOREIGN KEY ("target_user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_15c35422032e0b22b4ada95f48f" FOREIGN KEY ("inviter_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT "FK_6a15b051fe5050aa00a4b9ff0f6" FOREIGN KEY ("channel_id") REFERENCES "channels" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT "FK_3f4939aa1461e8af57fea3fb05d" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION - ) - `); - await queryRunner.query(` - INSERT INTO "invites"( - "code", - "temporary", - "uses", - "max_uses", - "max_age", - "created_at", - "expires_at", - "guild_id", - "channel_id", - "inviter_id", - "target_user_id", - "target_user_type", - "vanity_url" - ) - SELECT "code", - "temporary", - "uses", - "max_uses", - "max_age", - "created_at", - "expires_at", - "guild_id", - "channel_id", - "inviter_id", - "target_user_id", - "target_user_type", - "vanity_url" - FROM "temporary_invites" - `); - await queryRunner.query(` - DROP TABLE "temporary_invites" - `); - } - -} -- cgit 1.5.1