From b023741f5026289edccdb11cdfab1e6871b238e0 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 6 Dec 2022 23:00:08 +0100 Subject: [PATCH] server: remove integrations field from user --- .../backend/migration/1670359028055-removeIntegrations.js | 2 ++ packages/backend/src/models/entities/user-profile.ts | 5 ----- packages/backend/src/models/repositories/user.ts | 1 - packages/backend/src/models/schema/user.ts | 4 ---- .../backend/src/server/api/endpoints/admin/show-user.ts | 6 ------ packages/foundkey-js/src/entities.ts | 1 - 6 files changed, 2 insertions(+), 17 deletions(-) diff --git a/packages/backend/migration/1670359028055-removeIntegrations.js b/packages/backend/migration/1670359028055-removeIntegrations.js index fa8d3e4a0..fd0888a6e 100644 --- a/packages/backend/migration/1670359028055-removeIntegrations.js +++ b/packages/backend/migration/1670359028055-removeIntegrations.js @@ -11,9 +11,11 @@ export class removeIntegrations1670359028055 { 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"`); + await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "integrations"`); } async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "user_profile" ADD "integrations" jsonb NOT NULL DEFAULT '{}'`); 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`); diff --git a/packages/backend/src/models/entities/user-profile.ts b/packages/backend/src/models/entities/user-profile.ts index 58ab00d01..93358e17a 100644 --- a/packages/backend/src/models/entities/user-profile.ts +++ b/packages/backend/src/models/entities/user-profile.ts @@ -167,11 +167,6 @@ export class UserProfile { @JoinColumn() public pinnedPage: Page | null; - @Column('jsonb', { - default: {}, - }) - public integrations: Record; - @Index() @Column('boolean', { default: false, select: false, diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts index 56fd4e218..00dcf7f87 100644 --- a/packages/backend/src/models/repositories/user.ts +++ b/packages/backend/src/models/repositories/user.ts @@ -387,7 +387,6 @@ export const UserRepository = db.getRepository(User).extend({ hasUnreadMessagingMessage: this.getHasUnreadMessagingMessage(user.id), hasUnreadNotification: this.getHasUnreadNotification(user.id), hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id), - integrations: profile!.integrations, mutedWords: profile!.mutedWords, mutedInstances: profile!.mutedInstances, mutingNotificationTypes: profile!.mutingNotificationTypes, diff --git a/packages/backend/src/models/schema/user.ts b/packages/backend/src/models/schema/user.ts index dae8f692c..fcb61f918 100644 --- a/packages/backend/src/models/schema/user.ts +++ b/packages/backend/src/models/schema/user.ts @@ -352,10 +352,6 @@ export const packedMeDetailedOnlySchema = { type: 'boolean', nullable: false, optional: false, }, - integrations: { - type: 'object', - nullable: true, optional: false, - }, mutedWords: { type: 'array', nullable: false, optional: false, diff --git a/packages/backend/src/server/api/endpoints/admin/show-user.ts b/packages/backend/src/server/api/endpoints/admin/show-user.ts index bc9c193f8..d7cf37ea3 100644 --- a/packages/backend/src/server/api/endpoints/admin/show-user.ts +++ b/packages/backend/src/server/api/endpoints/admin/show-user.ts @@ -45,11 +45,6 @@ export default define(meta, paramDef, async (ps, me) => { }; } - const maskedKeys = ['accessToken', 'accessTokenSecret', 'refreshToken']; - Object.keys(profile.integrations).forEach(integration => { - maskedKeys.forEach(key => profile.integrations[integration][key] = ''); - }); - const signins = await Signins.findBy({ userId: user.id }); return { @@ -61,7 +56,6 @@ export default define(meta, paramDef, async (ps, me) => { carefulBot: profile.carefulBot, injectFeaturedNote: profile.injectFeaturedNote, receiveAnnouncementEmail: profile.receiveAnnouncementEmail, - integrations: profile.integrations, mutedWords: profile.mutedWords, mutedInstances: profile.mutedInstances, mutingNotificationTypes: profile.mutingNotificationTypes, diff --git a/packages/foundkey-js/src/entities.ts b/packages/foundkey-js/src/entities.ts index 2fd05c1cf..236b2a8a3 100644 --- a/packages/foundkey-js/src/entities.ts +++ b/packages/foundkey-js/src/entities.ts @@ -98,7 +98,6 @@ export type MeDetailed = UserDetailed & { hasUnreadSpecifiedNotes: boolean; hideOnlineStatus: boolean; injectFeaturedNote: boolean; - integrations: Record; isDeleted: boolean; isExplorable: boolean; mutedWords: string[][];