From 7ad6bbd32c2f368e8a3da9ad148d03fb945aca16 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 18 Oct 2023 23:48:05 +0200 Subject: [PATCH] [backend] Remove user list proxy account --- .../1697663824168-remote-nsfw-detection.ts | 26 +++--- .../1697665612162-remove-proxy-account.ts | 15 +++ .../backend/src/misc/fetch-proxy-account.ts | 11 --- packages/backend/src/models/entities/meta.ts | 12 --- .../src/server/api/endpoints/admin/meta.ts | 12 --- .../server/api/endpoints/admin/update-meta.ts | 5 - .../backend/src/server/api/endpoints/meta.ts | 14 +-- packages/backend/src/server/nodeinfo.ts | 5 - .../backend/src/services/user-list/push.ts | 10 -- packages/client/src/pages/admin/index.vue | 6 -- .../client/src/pages/admin/proxy-account.vue | 91 ------------------- packages/client/src/router.ts | 5 - 12 files changed, 29 insertions(+), 183 deletions(-) create mode 100644 packages/backend/src/migration/1697665612162-remove-proxy-account.ts delete mode 100644 packages/backend/src/misc/fetch-proxy-account.ts delete mode 100644 packages/client/src/pages/admin/proxy-account.vue diff --git a/packages/backend/src/migration/1697663824168-remote-nsfw-detection.ts b/packages/backend/src/migration/1697663824168-remote-nsfw-detection.ts index 45a659dd7..a77dce9f6 100644 --- a/packages/backend/src/migration/1697663824168-remote-nsfw-detection.ts +++ b/packages/backend/src/migration/1697663824168-remote-nsfw-detection.ts @@ -1,20 +1,20 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -export class RemoteNsfwDetection1697663824168 implements MigrationInterface { - name = 'RemoteNsfwDetection1697663824168' +export class RemoveNsfwDetection1697663824168 implements MigrationInterface { + name = 'RemoveNsfwDetection1697663824168' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP INDEX "public"."IDX_3b33dff77bb64b23c88151d23e"`); - await queryRunner.query(`DROP INDEX "public"."IDX_8bdcd3dd2bddb78014999a16ce"`); - await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN "maybeSensitive"`); - await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN "maybePorn"`); - await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "sensitiveMediaDetection"`); - await queryRunner.query(`DROP TYPE "public"."meta_sensitivemediadetection_enum"`); - await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "sensitiveMediaDetectionSensitivity"`); - await queryRunner.query(`DROP TYPE "public"."meta_sensitivemediadetectionsensitivity_enum"`); - await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "setSensitiveFlagAutomatically"`); - await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableSensitiveMediaDetectionForVideos"`); - await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "autoSensitive"`); + await queryRunner.query(`DROP INDEX IF EXISTS "public"."IDX_3b33dff77bb64b23c88151d23e"`); + await queryRunner.query(`DROP INDEX IF EXISTS "public"."IDX_8bdcd3dd2bddb78014999a16ce"`); + await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN IF EXISTS "maybeSensitive"`); + await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN IF EXISTS "maybePorn"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN IF EXISTS "sensitiveMediaDetection"`); + await queryRunner.query(`DROP TYPE IF EXISTS "public"."meta_sensitivemediadetection_enum"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN IF EXISTS "sensitiveMediaDetectionSensitivity"`); + await queryRunner.query(`DROP TYPE IF EXISTS "public"."meta_sensitivemediadetectionsensitivity_enum"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN IF EXISTS "setSensitiveFlagAutomatically"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN IF EXISTS "enableSensitiveMediaDetectionForVideos"`); + await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN IF EXISTS "autoSensitive"`); } public async down(queryRunner: QueryRunner): Promise { diff --git a/packages/backend/src/migration/1697665612162-remove-proxy-account.ts b/packages/backend/src/migration/1697665612162-remove-proxy-account.ts new file mode 100644 index 000000000..ff4d9050f --- /dev/null +++ b/packages/backend/src/migration/1697665612162-remove-proxy-account.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class RemoveProxyAccount1697665612162 implements MigrationInterface { + name = 'RemoveProxyAccount1697665612162' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "meta" DROP CONSTRAINT IF EXISTS "FK_ab1bc0c1e209daa77b8e8d212ad"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN IF EXISTS "proxyAccountId"`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "meta" ADD "proxyAccountId" character varying(32)`); + await queryRunner.query(`ALTER TABLE "meta" ADD CONSTRAINT "FK_ab1bc0c1e209daa77b8e8d212ad" FOREIGN KEY ("proxyAccountId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); + } +} diff --git a/packages/backend/src/misc/fetch-proxy-account.ts b/packages/backend/src/misc/fetch-proxy-account.ts deleted file mode 100644 index a277db6fb..000000000 --- a/packages/backend/src/misc/fetch-proxy-account.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { fetchMeta } from "./fetch-meta.js"; -import type { ILocalUser } from "@/models/entities/user.js"; -import { Users } from "@/models/index.js"; - -export async function fetchProxyAccount(): Promise { - const meta = await fetchMeta(); - if (meta.proxyAccountId == null) return null; - return (await Users.findOneByOrFail({ - id: meta.proxyAccountId, - })) as ILocalUser; -} diff --git a/packages/backend/src/models/entities/meta.ts b/packages/backend/src/models/entities/meta.ts index 0db5126d1..44152ba64 100644 --- a/packages/backend/src/models/entities/meta.ts +++ b/packages/backend/src/models/entities/meta.ts @@ -202,18 +202,6 @@ export class Meta { }) public cacheRemoteFiles: boolean; - @Column({ - ...id(), - nullable: true, - }) - public proxyAccountId: User["id"] | null; - - @ManyToOne((type) => User, { - onDelete: "SET NULL", - }) - @JoinColumn() - public proxyAccount: User | null; - @Column("boolean", { default: false, }) diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 373727a16..8e193380c 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -160,11 +160,6 @@ export const meta = { optional: false, nullable: false, }, - proxyAccountName: { - type: "string", - optional: false, - nullable: true, - }, recommendedInstances: { type: "array", optional: true, @@ -265,12 +260,6 @@ export const meta = { optional: true, nullable: true, }, - proxyAccountId: { - type: "string", - optional: true, - nullable: true, - format: "id", - }, twitterConsumerKey: { type: "string", optional: true, @@ -510,7 +499,6 @@ export default define(meta, paramDef, async (ps, me) => { secureMode: instance.secureMode, hcaptchaSecretKey: instance.hcaptchaSecretKey, recaptchaSecretKey: instance.recaptchaSecretKey, - proxyAccountId: instance.proxyAccountId, twitterConsumerKey: instance.twitterConsumerKey, twitterConsumerSecret: instance.twitterConsumerSecret, githubClientId: instance.githubClientId, 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 3224995f8..89f657ef4 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -101,7 +101,6 @@ export const paramDef = { enableRecaptcha: { type: "boolean" }, recaptchaSiteKey: { type: "string", nullable: true }, recaptchaSecretKey: { type: "string", nullable: true }, - proxyAccountId: { type: "string", format: "misskey:id", nullable: true }, maintainerName: { type: "string", nullable: true }, maintainerEmail: { type: "string", nullable: true }, pinnedPages: { @@ -336,10 +335,6 @@ export default define(meta, paramDef, async (ps, me) => { set.recaptchaSecretKey = ps.recaptchaSecretKey; } - if (ps.proxyAccountId !== undefined) { - set.proxyAccountId = ps.proxyAccountId; - } - if (ps.maintainerName !== undefined) { set.maintainerName = ps.maintainerName; } diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 52319a383..7315346cb 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -271,11 +271,6 @@ export const meta = { optional: false, nullable: false, }, - proxyAccountName: { - type: "string", - optional: false, - nullable: true, - }, images: { type: 'object', optional: false, nullable: false, @@ -488,20 +483,13 @@ export default define(meta, paramDef, async (ps, me) => { }; if (ps.detail) { - if (!instance.privateMode || me) { - const proxyAccount = instance.proxyAccountId - ? await Users.pack(instance.proxyAccountId).catch(() => null) - : null; - response.proxyAccountName = proxyAccount ? proxyAccount.username : null; - } - response.features = { registration: !instance.disableRegistration, localTimeLine: !instance.disableLocalTimeline, recommendedTimeline: !instance.disableRecommendedTimeline, globalTimeLine: !instance.disableGlobalTimeline, emailRequiredForSignup: instance.emailRequiredForSignup, - searchFilters: config.meilisearch ? true : false, + searchFilters: !!config.meilisearch, hcaptcha: instance.enableHcaptcha, recaptcha: instance.enableRecaptcha, objectStorage: instance.useObjectStorage, diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index 6089cfb5b..29877abf9 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -44,10 +44,6 @@ const nodeinfo2 = async () => { Notes.count({ where: { userHost: IsNull() } }), ]); - const proxyAccount = meta.proxyAccountId - ? await Users.pack(meta.proxyAccountId).catch(() => null) - : null; - return { software: { name: "iceshrimp", @@ -93,7 +89,6 @@ const nodeinfo2 = async () => { enableGithubIntegration: meta.enableGithubIntegration, enableDiscordIntegration: meta.enableDiscordIntegration, enableEmail: meta.enableEmail, - proxyAccountName: proxyAccount ? proxyAccount.username : null, themeColor: meta.themeColor || "#31748f", }, }; diff --git a/packages/backend/src/services/user-list/push.ts b/packages/backend/src/services/user-list/push.ts index 01bb06601..7866ca17f 100644 --- a/packages/backend/src/services/user-list/push.ts +++ b/packages/backend/src/services/user-list/push.ts @@ -4,8 +4,6 @@ import type { UserList } from "@/models/entities/user-list.js"; import { UserListJoinings, Users } from "@/models/index.js"; import type { UserListJoining } from "@/models/entities/user-list-joining.js"; import { genId } from "@/misc/gen-id.js"; -import { fetchProxyAccount } from "@/misc/fetch-proxy-account.js"; -import createFollowing from "../following/create.js"; export async function pushUserToUserList(target: User, list: UserList) { await UserListJoinings.insert({ @@ -16,12 +14,4 @@ export async function pushUserToUserList(target: User, list: UserList) { } as UserListJoining); publishUserListStream(list.id, "userAdded", await Users.pack(target)); - - // このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする - if (Users.isRemoteUser(target)) { - const proxy = await fetchProxyAccount(); - if (proxy) { - createFollowing(proxy, target); - } - } } diff --git a/packages/client/src/pages/admin/index.vue b/packages/client/src/pages/admin/index.vue index de34071cb..4f2f1ded0 100644 --- a/packages/client/src/pages/admin/index.vue +++ b/packages/client/src/pages/admin/index.vue @@ -295,12 +295,6 @@ const menuDef = $computed(() => [ to: "/admin/hashtags", active: currentPage?.route.name === "hashtags", }, - { - icon: "ph-ghost ph-bold ph-lg", - text: i18n.ts.proxyAccount, - to: "/admin/proxy-account", - active: currentPage?.route.name === "proxy-account", - }, { icon: "ph-database ph-bold ph-lg", text: i18n.ts.database, diff --git a/packages/client/src/pages/admin/proxy-account.vue b/packages/client/src/pages/admin/proxy-account.vue deleted file mode 100644 index 7d72b0ac0..000000000 --- a/packages/client/src/pages/admin/proxy-account.vue +++ /dev/null @@ -1,91 +0,0 @@ - - - diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index f2488a45a..925bede67 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -529,11 +529,6 @@ export const routes = [ name: "instance-block", component: page(() => import("./pages/admin/instance-block.vue")), }, - { - path: "/proxy-account", - name: "proxy-account", - component: page(() => import("./pages/admin/proxy-account.vue")), - }, { path: "/other-settings", name: "other-settings",