From b4b1204f77e9736af0a754115d98b2ab720c013f Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 6 Dec 2022 21:47:59 +0100 Subject: [PATCH] server: remove integration-related fields from meta --- .../1670359028055-removeIntegrations.js | 27 ++++++++++ packages/backend/src/models/entities/meta.ts | 51 ------------------- .../src/server/api/endpoints/admin/meta.ts | 45 ---------------- .../server/api/endpoints/admin/update-meta.ts | 45 ---------------- .../backend/src/server/api/endpoints/meta.ts | 31 ----------- 5 files changed, 27 insertions(+), 172 deletions(-) create mode 100644 packages/backend/migration/1670359028055-removeIntegrations.js diff --git a/packages/backend/migration/1670359028055-removeIntegrations.js b/packages/backend/migration/1670359028055-removeIntegrations.js new file mode 100644 index 000000000..fa8d3e4a0 --- /dev/null +++ b/packages/backend/migration/1670359028055-removeIntegrations.js @@ -0,0 +1,27 @@ +export class removeIntegrations1670359028055 { + name = 'removeIntegrations1670359028055' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableTwitterIntegration"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "twitterConsumerKey"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "twitterConsumerSecret"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableGithubIntegration"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "githubClientId"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "githubClientSecret"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableDiscordIntegration"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "discordClientId"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "discordClientSecret"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ADD "discordClientSecret" character varying(128)`); + await queryRunner.query(`ALTER TABLE "meta" ADD "discordClientId" character varying(128)`); + await queryRunner.query(`ALTER TABLE "meta" ADD "enableDiscordIntegration" boolean NOT NULL DEFAULT false`); + await queryRunner.query(`ALTER TABLE "meta" ADD "githubClientSecret" character varying(128)`); + await queryRunner.query(`ALTER TABLE "meta" ADD "githubClientId" character varying(128)`); + await queryRunner.query(`ALTER TABLE "meta" ADD "enableGithubIntegration" boolean NOT NULL DEFAULT false`); + await queryRunner.query(`ALTER TABLE "meta" ADD "twitterConsumerSecret" character varying(128)`); + await queryRunner.query(`ALTER TABLE "meta" ADD "twitterConsumerKey" character varying(128)`); + await queryRunner.query(`ALTER TABLE "meta" ADD "enableTwitterIntegration" boolean NOT NULL DEFAULT false`); + } +} diff --git a/packages/backend/src/models/entities/meta.ts b/packages/backend/src/models/entities/meta.ts index c812b882a..d30bfd67e 100644 --- a/packages/backend/src/models/entities/meta.ts +++ b/packages/backend/src/models/entities/meta.ts @@ -246,57 +246,6 @@ export class Meta { }) public swPrivateKey: string; - @Column('boolean', { - default: false, - }) - public enableTwitterIntegration: boolean; - - @Column('varchar', { - length: 128, - nullable: true, - }) - public twitterConsumerKey: string | null; - - @Column('varchar', { - length: 128, - nullable: true, - }) - public twitterConsumerSecret: string | null; - - @Column('boolean', { - default: false, - }) - public enableGithubIntegration: boolean; - - @Column('varchar', { - length: 128, - nullable: true, - }) - public githubClientId: string | null; - - @Column('varchar', { - length: 128, - nullable: true, - }) - public githubClientSecret: string | null; - - @Column('boolean', { - default: false, - }) - public enableDiscordIntegration: boolean; - - @Column('varchar', { - length: 128, - nullable: true, - }) - public discordClientId: string | null; - - @Column('varchar', { - length: 128, - nullable: true, - }) - public discordClientSecret: string | null; - @Column('enum', { enum: TranslationService, nullable: true, diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index ddd64f6b1..57e60f1c6 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -102,18 +102,6 @@ export const meta = { type: 'boolean', optional: false, nullable: false, }, - enableTwitterIntegration: { - type: 'boolean', - optional: false, nullable: false, - }, - enableGithubIntegration: { - type: 'boolean', - optional: false, nullable: false, - }, - enableDiscordIntegration: { - type: 'boolean', - optional: false, nullable: false, - }, translatorAvailable: { type: 'boolean', optional: false, nullable: false, @@ -163,30 +151,6 @@ export const meta = { optional: true, nullable: true, format: 'id', }, - twitterConsumerKey: { - type: 'string', - optional: true, nullable: true, - }, - twitterConsumerSecret: { - type: 'string', - optional: true, nullable: true, - }, - githubClientId: { - type: 'string', - optional: true, nullable: true, - }, - githubClientSecret: { - type: 'string', - optional: true, nullable: true, - }, - discordClientId: { - type: 'string', - optional: true, nullable: true, - }, - discordClientSecret: { - type: 'string', - optional: true, nullable: true, - }, summaryProxy: { type: 'string', optional: true, nullable: true, @@ -324,9 +288,6 @@ export default define(meta, paramDef, async (ps, me) => { defaultLightTheme: instance.defaultLightTheme, defaultDarkTheme: instance.defaultDarkTheme, enableEmail: instance.enableEmail, - enableTwitterIntegration: instance.enableTwitterIntegration, - enableGithubIntegration: instance.enableGithubIntegration, - enableDiscordIntegration: instance.enableDiscordIntegration, pinnedPages: instance.pinnedPages, pinnedClipId: instance.pinnedClipId, cacheRemoteFiles: instance.cacheRemoteFiles, @@ -338,12 +299,6 @@ export default define(meta, paramDef, async (ps, me) => { hcaptchaSecretKey: instance.hcaptchaSecretKey, recaptchaSecretKey: instance.recaptchaSecretKey, proxyAccountId: instance.proxyAccountId, - twitterConsumerKey: instance.twitterConsumerKey, - twitterConsumerSecret: instance.twitterConsumerSecret, - githubClientId: instance.githubClientId, - githubClientSecret: instance.githubClientSecret, - discordClientId: instance.discordClientId, - discordClientSecret: instance.discordClientSecret, summalyProxy: instance.summalyProxy, email: instance.email, smtpSecure: instance.smtpSecure, diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index c6913a675..965140018 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -60,15 +60,6 @@ export const paramDef = { deeplAuthKey: { type: 'string', nullable: true }, libreTranslateAuthKey: { type: 'string', nullable: true }, libreTranslateEndpoint: { type: 'string', nullable: true }, - enableTwitterIntegration: { type: 'boolean' }, - twitterConsumerKey: { type: 'string', nullable: true }, - twitterConsumerSecret: { type: 'string', nullable: true }, - enableGithubIntegration: { type: 'boolean' }, - githubClientId: { type: 'string', nullable: true }, - githubClientSecret: { type: 'string', nullable: true }, - enableDiscordIntegration: { type: 'boolean' }, - discordClientId: { type: 'string', nullable: true }, - discordClientSecret: { type: 'string', nullable: true }, enableEmail: { type: 'boolean' }, email: { type: 'string', nullable: true }, smtpSecure: { type: 'boolean' }, @@ -230,42 +221,6 @@ export default define(meta, paramDef, async (ps, me) => { set.summalyProxy = ps.summalyProxy; } - if (ps.enableTwitterIntegration !== undefined) { - set.enableTwitterIntegration = ps.enableTwitterIntegration; - } - - if (ps.twitterConsumerKey !== undefined) { - set.twitterConsumerKey = ps.twitterConsumerKey; - } - - if (ps.twitterConsumerSecret !== undefined) { - set.twitterConsumerSecret = ps.twitterConsumerSecret; - } - - if (ps.enableGithubIntegration !== undefined) { - set.enableGithubIntegration = ps.enableGithubIntegration; - } - - if (ps.githubClientId !== undefined) { - set.githubClientId = ps.githubClientId; - } - - if (ps.githubClientSecret !== undefined) { - set.githubClientSecret = ps.githubClientSecret; - } - - if (ps.enableDiscordIntegration !== undefined) { - set.enableDiscordIntegration = ps.enableDiscordIntegration; - } - - if (ps.discordClientId !== undefined) { - set.discordClientId = ps.discordClientId; - } - - if (ps.discordClientSecret !== undefined) { - set.discordClientSecret = ps.discordClientSecret; - } - if (ps.enableEmail !== undefined) { set.enableEmail = ps.enableEmail; } diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 569b8f56b..a36178c26 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -170,18 +170,6 @@ export const meta = { type: 'boolean', optional: false, nullable: false, }, - enableTwitterIntegration: { - type: 'boolean', - optional: false, nullable: false, - }, - enableGithubIntegration: { - type: 'boolean', - optional: false, nullable: false, - }, - enableDiscordIntegration: { - type: 'boolean', - optional: false, nullable: false, - }, translatorAvailable: { type: 'boolean', optional: false, nullable: false, @@ -222,18 +210,6 @@ export const meta = { type: 'boolean', optional: false, nullable: false, }, - twitter: { - type: 'boolean', - optional: false, nullable: false, - }, - github: { - type: 'boolean', - optional: false, nullable: false, - }, - discord: { - type: 'boolean', - optional: false, nullable: false, - }, serviceWorker: { type: 'boolean', optional: true, nullable: false, @@ -314,10 +290,6 @@ export default define(meta, paramDef, async (ps, me) => { defaultDarkTheme: instance.defaultDarkTheme, enableEmail: instance.enableEmail, - enableTwitterIntegration: instance.enableTwitterIntegration, - enableGithubIntegration: instance.enableGithubIntegration, - enableDiscordIntegration: instance.enableDiscordIntegration, - translatorAvailable: translatorAvailable(instance), pinnedPages: instance.pinnedPages, @@ -338,9 +310,6 @@ export default define(meta, paramDef, async (ps, me) => { hcaptcha: instance.enableHcaptcha, recaptcha: instance.enableRecaptcha, objectStorage: instance.useObjectStorage, - twitter: instance.enableTwitterIntegration, - github: instance.enableGithubIntegration, - discord: instance.enableDiscordIntegration, serviceWorker: true, miauth: true, },