mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-29 05:29:15 +00:00
Cherrypick fixups
This commit is contained in:
@@ -38,6 +38,7 @@ export function ErrorHandler(
|
||||
|
||||
if (error instanceof HTTPError && error.code) {
|
||||
code = httpcode = error.code;
|
||||
// @ts-expect-error - we make it exist
|
||||
if (error.data) data = error.data;
|
||||
} else if (error instanceof ApiError) {
|
||||
code = error.code;
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getIpAdress } from "@spacebar/api";
|
||||
import { Config, getRights, listenEvent } from "@spacebar/util";
|
||||
import { Config, getRights, listenEvent, getIpAdress } from "@spacebar/util";
|
||||
import { NextFunction, Request, Response, Router } from "express";
|
||||
import { API_PREFIX_TRAILING_SLASH } from "./Authentication";
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getIpAdress, route, verifyCaptcha } from "@spacebar/api";
|
||||
import { Config, Email, ForgotPasswordSchema, User } from "@spacebar/util";
|
||||
import { route, verifyCaptcha } from "@spacebar/api";
|
||||
import { Config, Email, ForgotPasswordSchema, getIpAdress, User } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { random, route } from "@spacebar/api";
|
||||
import { Config, ValidRegistrationToken } from "@spacebar/util";
|
||||
import { route } from "@spacebar/api";
|
||||
import { Config, generateRandomString, ValidRegistrationToken } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
const router: Router = Router();
|
||||
@@ -51,7 +51,7 @@ router.get(
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const token = ValidRegistrationToken.create({
|
||||
token: random(length),
|
||||
token: generateRandomString(length),
|
||||
expires_at: new Date(
|
||||
Date.now() +
|
||||
Config.get().security
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { IPAnalysis, getIpAdress, route } from "@spacebar/api";
|
||||
import { route } from "@spacebar/api";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { getIpAdress, IPAnalysis } from "@spacebar/util";
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getIpAdress, route, verifyCaptcha } from "@spacebar/api";
|
||||
import { route, verifyCaptcha } from "@spacebar/api";
|
||||
import {
|
||||
Config,
|
||||
FieldErrors,
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
User,
|
||||
WebAuthn,
|
||||
generateToken,
|
||||
generateWebAuthnTicket,
|
||||
generateWebAuthnTicket, getIpAdress,
|
||||
} from "@spacebar/util";
|
||||
import bcrypt from "bcrypt";
|
||||
import crypto from "crypto";
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
IPAnalysis,
|
||||
getIpAdress,
|
||||
isProxy,
|
||||
route,
|
||||
verifyCaptcha,
|
||||
} from "@spacebar/api";
|
||||
@@ -30,7 +27,7 @@ import {
|
||||
RegisterSchema,
|
||||
User,
|
||||
ValidRegistrationToken,
|
||||
generateToken,
|
||||
generateToken, getIpAdress, IPAnalysis, isProxy,
|
||||
} from "@spacebar/util";
|
||||
import bcrypt from "bcrypt";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getIpAdress, route, verifyCaptcha } from "@spacebar/api";
|
||||
import { route, verifyCaptcha } from "@spacebar/api";
|
||||
import {
|
||||
checkToken,
|
||||
Config,
|
||||
FieldErrors,
|
||||
generateToken,
|
||||
generateToken, getIpAdress,
|
||||
User,
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { random, route } from "@spacebar/api";
|
||||
import { route } from "@spacebar/api";
|
||||
import {
|
||||
Channel,
|
||||
Guild,
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
PublicInviteRelation,
|
||||
User,
|
||||
emitEvent,
|
||||
isTextChannel,
|
||||
isTextChannel, generateRandomString,
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
@@ -70,7 +70,7 @@ router.post(
|
||||
: new Date(body.max_age * 1000 + Date.now());
|
||||
|
||||
const invite = await Invite.create({
|
||||
code: random(),
|
||||
code: generateRandomString(),
|
||||
temporary: body.temporary || true,
|
||||
uses: 0,
|
||||
max_uses: body.max_uses ? Math.max(0, body.max_uses) : 0,
|
||||
|
||||
@@ -427,17 +427,18 @@ router.post(
|
||||
read_state = ReadState.create({ user_id: req.user_id, channel_id });
|
||||
read_state.last_message_id = message.id;
|
||||
|
||||
let blocks = (
|
||||
const blocks = (
|
||||
await PluginEventHandler.preMessageEvent({
|
||||
message
|
||||
} as PreMessageEventArgs)
|
||||
).filter((x) => x.cancel);
|
||||
if (blocks.length > 0)
|
||||
if (blocks.length > 0) {
|
||||
console.log("[Message] Pre-message event handler blocked message send:", message, blocks)
|
||||
throw new HTTPError(
|
||||
"Message denied.",
|
||||
400,
|
||||
blocks.filter((x) => x.blockReason).map((x) => x.blockReason)
|
||||
);
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
read_state.save(),
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getIpAdress, route } from "@spacebar/api";
|
||||
import { route } from "@spacebar/api";
|
||||
import {
|
||||
APIBansArray,
|
||||
Ban,
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
GuildBansResponse,
|
||||
Member,
|
||||
User,
|
||||
emitEvent,
|
||||
emitEvent, getIpAdress,
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getIpAdress, route } from "@spacebar/api";
|
||||
import { route } from "@spacebar/api";
|
||||
import {
|
||||
Ban,
|
||||
DiscordApiErrors,
|
||||
GuildBanAddEvent,
|
||||
Member,
|
||||
User,
|
||||
emitEvent,
|
||||
emitEvent, getIpAdress,
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getIpAdress, getVoiceRegions, route } from "@spacebar/api";
|
||||
import { Guild } from "@spacebar/util";
|
||||
import { getVoiceRegions, route } from "@spacebar/api";
|
||||
import { getIpAdress, Guild } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { generateCode, route } from "@spacebar/api";
|
||||
import { Guild, Template } from "@spacebar/util";
|
||||
import { route } from "@spacebar/api";
|
||||
import { generateCode, Guild, Template } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { random, route } from "@spacebar/api";
|
||||
import { route } from "@spacebar/api";
|
||||
import {
|
||||
Channel,
|
||||
DiscordApiErrors,
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
Invite,
|
||||
Member,
|
||||
Permissions,
|
||||
generateRandomString
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
@@ -77,7 +78,7 @@ router.get(
|
||||
const expires_at = new Date(max_age * 1000 + Date.now());
|
||||
|
||||
invite = await Invite.create({
|
||||
code: random(),
|
||||
code: generateRandomString(),
|
||||
temporary: false,
|
||||
uses: 0,
|
||||
max_uses: 0,
|
||||
|
||||
@@ -26,7 +26,6 @@ import {
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { verifyToken } from "node-2fa";
|
||||
import { route } from "../../../../..";
|
||||
|
||||
const router = Router();
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getIpAdress, getVoiceRegions, route } from "@spacebar/api";
|
||||
import { getVoiceRegions, route } from "@spacebar/api";
|
||||
import { getIpAdress } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Config } from "@spacebar/util";
|
||||
import { distanceBetweenLocations, IPAnalysis } from "../utility/ipAddress";
|
||||
import { Config, distanceBetweenLocations, IPAnalysis } from "@spacebar/util";
|
||||
|
||||
export async function getVoiceRegions(ipAddress: string, vip: boolean) {
|
||||
const regions = Config.get().regions;
|
||||
|
||||
@@ -16,13 +16,8 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from "./utility/Base64";
|
||||
export * from "./utility/ipAddress";
|
||||
export * from "./handlers/Message";
|
||||
export * from "./utility/passwordStrength";
|
||||
export * from "./utility/RandomInviteID";
|
||||
export * from "./handlers/route";
|
||||
export * from "./utility/String";
|
||||
export * from "./handlers/Voice";
|
||||
export * from "./utility/captcha";
|
||||
export * from "./utility/EmbedHandlers";
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Request } from "express";
|
||||
import { ntob } from "./Base64";
|
||||
import { FieldErrors } from "@spacebar/util";
|
||||
|
||||
export function checkLength(
|
||||
str: string,
|
||||
min: number,
|
||||
max: number,
|
||||
key: string,
|
||||
req: Request,
|
||||
) {
|
||||
if (str.length < min || str.length > max) {
|
||||
throw FieldErrors({
|
||||
[key]: {
|
||||
code: "BASE_TYPE_BAD_LENGTH",
|
||||
message: req.t("common:field.BASE_TYPE_BAD_LENGTH", {
|
||||
length: `${min} - ${max}`,
|
||||
}),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function generateCode() {
|
||||
return ntob(Date.now() + Math.randomIntBetween(0, 10000));
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
PluginManifest,
|
||||
PreMessageEventArgs,
|
||||
PreMessageEventResult
|
||||
} from "@fosscord/util";
|
||||
} from "@spacebar/util";
|
||||
import { TestSettings } from "./TestSettings";
|
||||
|
||||
export default class TestPlugin implements Plugin {
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class PluginConfigs1660404619978 implements MigrationInterface {
|
||||
name = "PluginConfigs1660404619978";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "plugin_config" (
|
||||
"key" character varying NOT NULL,
|
||||
"value" text,
|
||||
CONSTRAINT "PK_aa929ece56c59233b85a16f62ef" PRIMARY KEY ("key")
|
||||
)
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "plugin_config"
|
||||
`);
|
||||
}
|
||||
}
|
||||
@@ -1,828 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
name = "UpdateMigrations1660534525799";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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<void> {
|
||||
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"
|
||||
`);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class syncRebase15aug20221660565540177 implements MigrationInterface {
|
||||
name = "syncRebase15aug20221660565540177";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "plugin_config" ("key" varchar PRIMARY KEY NOT NULL, "value" text)
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "plugin_config"
|
||||
`);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import crypto from "crypto";
|
||||
// TODO: 'random'? seriously? who named this?
|
||||
// And why is this even here? Just use cryto.randomBytes?
|
||||
|
||||
export function random(length = 6) {
|
||||
export function generateRandomString(length = 6) {
|
||||
// Declare all characters
|
||||
const chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
@@ -51,5 +51,5 @@ export function snowflakeBasedInvite() {
|
||||
snowflake = snowflake / base;
|
||||
}
|
||||
|
||||
return str.substr(3, 8).split("").reverse().join("");
|
||||
return str.substring(3, 8).split("").reverse().join("");
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
import { SPECIAL_CHAR } from "./Regex";
|
||||
import { ntob } from "./Base64";
|
||||
|
||||
export function trimSpecial(str?: string): string {
|
||||
if (!str) return "";
|
||||
@@ -37,4 +38,8 @@ export function centerString(str: string, len: number): string {
|
||||
const pad = len - str.length;
|
||||
const padLeft = Math.floor(pad / 2) + str.length;
|
||||
return str.padStart(padLeft).padEnd(len);
|
||||
}
|
||||
}
|
||||
|
||||
export function generateCode() {
|
||||
return ntob(Date.now() + Math.randomIntBetween(0, 10000));
|
||||
}
|
||||
|
||||
@@ -50,4 +50,5 @@ export * from "./NameValidation";
|
||||
export * from "./InvisibleCharacters";
|
||||
export * from "./Environment";
|
||||
export * from "./Logo";
|
||||
export * from "./Paths";
|
||||
export * from "./ipAddress";
|
||||
export * from "./RandomInviteID";
|
||||
Reference in New Issue
Block a user