mirror of
https://github.com/spacebarchat/server.git
synced 2026-04-28 06:15:33 +00:00
Fix updated client stuff...
This commit is contained in:
+110
-52
@@ -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#"
|
||||
}
|
||||
}
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -117,6 +117,11 @@ export function route(opts: RouteOptions) {
|
||||
const valid = validate(normalizeBody(req.body));
|
||||
if (!valid) {
|
||||
const fields: Record<string, { code?: string; message: string }> = {};
|
||||
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);
|
||||
}
|
||||
|
||||
+2
-1
@@ -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"
|
||||
|
||||
@@ -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"));
|
||||
execIn("node scripts/generate_schema.js", path.join("..", "api"));
|
||||
+2
-1
@@ -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|
|
||||
|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|
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<Channel>,
|
||||
|
||||
@@ -185,8 +185,10 @@ export class User extends BaseClass {
|
||||
notes: { [key: string]: string } = {}; //key is ID of user
|
||||
|
||||
async save(): Promise<any> {
|
||||
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() {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup51660265930624 implements MigrationInterface {
|
||||
name = 'CodeCleanup51660265930624'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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<void> {
|
||||
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\`
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup51660265907544 implements MigrationInterface {
|
||||
name = 'CodeCleanup51660265907544'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "channels" DROP COLUMN "default_thread_rate_limit_per_user"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "channels" DROP COLUMN "flags"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,459 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CodeCleanup41660260539853 implements MigrationInterface {
|
||||
name = 'CodeCleanup41660260539853'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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<void> {
|
||||
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"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user