[backend] Remove user list proxy account

This commit is contained in:
Laura Hausmann 2023-10-18 23:48:05 +02:00
parent ed25373bc7
commit 7ad6bbd32c
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
12 changed files with 29 additions and 183 deletions

View file

@ -1,20 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm"; import { MigrationInterface, QueryRunner } from "typeorm";
export class RemoteNsfwDetection1697663824168 implements MigrationInterface { export class RemoveNsfwDetection1697663824168 implements MigrationInterface {
name = 'RemoteNsfwDetection1697663824168' name = 'RemoveNsfwDetection1697663824168'
public async up(queryRunner: QueryRunner): Promise<void> { public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "public"."IDX_3b33dff77bb64b23c88151d23e"`); await queryRunner.query(`DROP INDEX IF EXISTS "public"."IDX_3b33dff77bb64b23c88151d23e"`);
await queryRunner.query(`DROP INDEX "public"."IDX_8bdcd3dd2bddb78014999a16ce"`); await queryRunner.query(`DROP INDEX IF EXISTS "public"."IDX_8bdcd3dd2bddb78014999a16ce"`);
await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN "maybeSensitive"`); await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN IF EXISTS "maybeSensitive"`);
await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN "maybePorn"`); await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN IF EXISTS "maybePorn"`);
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "sensitiveMediaDetection"`); await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN IF EXISTS "sensitiveMediaDetection"`);
await queryRunner.query(`DROP TYPE "public"."meta_sensitivemediadetection_enum"`); await queryRunner.query(`DROP TYPE IF EXISTS "public"."meta_sensitivemediadetection_enum"`);
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "sensitiveMediaDetectionSensitivity"`); await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN IF EXISTS "sensitiveMediaDetectionSensitivity"`);
await queryRunner.query(`DROP TYPE "public"."meta_sensitivemediadetectionsensitivity_enum"`); await queryRunner.query(`DROP TYPE IF EXISTS "public"."meta_sensitivemediadetectionsensitivity_enum"`);
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "setSensitiveFlagAutomatically"`); await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN IF EXISTS "setSensitiveFlagAutomatically"`);
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableSensitiveMediaDetectionForVideos"`); await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN IF EXISTS "enableSensitiveMediaDetectionForVideos"`);
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "autoSensitive"`); await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN IF EXISTS "autoSensitive"`);
} }
public async down(queryRunner: QueryRunner): Promise<void> { public async down(queryRunner: QueryRunner): Promise<void> {

View file

@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class RemoveProxyAccount1697665612162 implements MigrationInterface {
name = 'RemoveProxyAccount1697665612162'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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`);
}
}

View file

@ -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<ILocalUser | null> {
const meta = await fetchMeta();
if (meta.proxyAccountId == null) return null;
return (await Users.findOneByOrFail({
id: meta.proxyAccountId,
})) as ILocalUser;
}

View file

@ -202,18 +202,6 @@ export class Meta {
}) })
public cacheRemoteFiles: boolean; 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", { @Column("boolean", {
default: false, default: false,
}) })

View file

@ -160,11 +160,6 @@ export const meta = {
optional: false, optional: false,
nullable: false, nullable: false,
}, },
proxyAccountName: {
type: "string",
optional: false,
nullable: true,
},
recommendedInstances: { recommendedInstances: {
type: "array", type: "array",
optional: true, optional: true,
@ -265,12 +260,6 @@ export const meta = {
optional: true, optional: true,
nullable: true, nullable: true,
}, },
proxyAccountId: {
type: "string",
optional: true,
nullable: true,
format: "id",
},
twitterConsumerKey: { twitterConsumerKey: {
type: "string", type: "string",
optional: true, optional: true,
@ -510,7 +499,6 @@ export default define(meta, paramDef, async (ps, me) => {
secureMode: instance.secureMode, secureMode: instance.secureMode,
hcaptchaSecretKey: instance.hcaptchaSecretKey, hcaptchaSecretKey: instance.hcaptchaSecretKey,
recaptchaSecretKey: instance.recaptchaSecretKey, recaptchaSecretKey: instance.recaptchaSecretKey,
proxyAccountId: instance.proxyAccountId,
twitterConsumerKey: instance.twitterConsumerKey, twitterConsumerKey: instance.twitterConsumerKey,
twitterConsumerSecret: instance.twitterConsumerSecret, twitterConsumerSecret: instance.twitterConsumerSecret,
githubClientId: instance.githubClientId, githubClientId: instance.githubClientId,

View file

@ -101,7 +101,6 @@ export const paramDef = {
enableRecaptcha: { type: "boolean" }, enableRecaptcha: { type: "boolean" },
recaptchaSiteKey: { type: "string", nullable: true }, recaptchaSiteKey: { type: "string", nullable: true },
recaptchaSecretKey: { type: "string", nullable: true }, recaptchaSecretKey: { type: "string", nullable: true },
proxyAccountId: { type: "string", format: "misskey:id", nullable: true },
maintainerName: { type: "string", nullable: true }, maintainerName: { type: "string", nullable: true },
maintainerEmail: { type: "string", nullable: true }, maintainerEmail: { type: "string", nullable: true },
pinnedPages: { pinnedPages: {
@ -336,10 +335,6 @@ export default define(meta, paramDef, async (ps, me) => {
set.recaptchaSecretKey = ps.recaptchaSecretKey; set.recaptchaSecretKey = ps.recaptchaSecretKey;
} }
if (ps.proxyAccountId !== undefined) {
set.proxyAccountId = ps.proxyAccountId;
}
if (ps.maintainerName !== undefined) { if (ps.maintainerName !== undefined) {
set.maintainerName = ps.maintainerName; set.maintainerName = ps.maintainerName;
} }

View file

@ -271,11 +271,6 @@ export const meta = {
optional: false, optional: false,
nullable: false, nullable: false,
}, },
proxyAccountName: {
type: "string",
optional: false,
nullable: true,
},
images: { images: {
type: 'object', type: 'object',
optional: false, nullable: false, optional: false, nullable: false,
@ -488,20 +483,13 @@ export default define(meta, paramDef, async (ps, me) => {
}; };
if (ps.detail) { 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 = { response.features = {
registration: !instance.disableRegistration, registration: !instance.disableRegistration,
localTimeLine: !instance.disableLocalTimeline, localTimeLine: !instance.disableLocalTimeline,
recommendedTimeline: !instance.disableRecommendedTimeline, recommendedTimeline: !instance.disableRecommendedTimeline,
globalTimeLine: !instance.disableGlobalTimeline, globalTimeLine: !instance.disableGlobalTimeline,
emailRequiredForSignup: instance.emailRequiredForSignup, emailRequiredForSignup: instance.emailRequiredForSignup,
searchFilters: config.meilisearch ? true : false, searchFilters: !!config.meilisearch,
hcaptcha: instance.enableHcaptcha, hcaptcha: instance.enableHcaptcha,
recaptcha: instance.enableRecaptcha, recaptcha: instance.enableRecaptcha,
objectStorage: instance.useObjectStorage, objectStorage: instance.useObjectStorage,

View file

@ -44,10 +44,6 @@ const nodeinfo2 = async () => {
Notes.count({ where: { userHost: IsNull() } }), Notes.count({ where: { userHost: IsNull() } }),
]); ]);
const proxyAccount = meta.proxyAccountId
? await Users.pack(meta.proxyAccountId).catch(() => null)
: null;
return { return {
software: { software: {
name: "iceshrimp", name: "iceshrimp",
@ -93,7 +89,6 @@ const nodeinfo2 = async () => {
enableGithubIntegration: meta.enableGithubIntegration, enableGithubIntegration: meta.enableGithubIntegration,
enableDiscordIntegration: meta.enableDiscordIntegration, enableDiscordIntegration: meta.enableDiscordIntegration,
enableEmail: meta.enableEmail, enableEmail: meta.enableEmail,
proxyAccountName: proxyAccount ? proxyAccount.username : null,
themeColor: meta.themeColor || "#31748f", themeColor: meta.themeColor || "#31748f",
}, },
}; };

View file

@ -4,8 +4,6 @@ import type { UserList } from "@/models/entities/user-list.js";
import { UserListJoinings, Users } from "@/models/index.js"; import { UserListJoinings, Users } from "@/models/index.js";
import type { UserListJoining } from "@/models/entities/user-list-joining.js"; import type { UserListJoining } from "@/models/entities/user-list-joining.js";
import { genId } from "@/misc/gen-id.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) { export async function pushUserToUserList(target: User, list: UserList) {
await UserListJoinings.insert({ await UserListJoinings.insert({
@ -16,12 +14,4 @@ export async function pushUserToUserList(target: User, list: UserList) {
} as UserListJoining); } as UserListJoining);
publishUserListStream(list.id, "userAdded", await Users.pack(target)); publishUserListStream(list.id, "userAdded", await Users.pack(target));
// このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする
if (Users.isRemoteUser(target)) {
const proxy = await fetchProxyAccount();
if (proxy) {
createFollowing(proxy, target);
}
}
} }

View file

@ -295,12 +295,6 @@ const menuDef = $computed(() => [
to: "/admin/hashtags", to: "/admin/hashtags",
active: currentPage?.route.name === "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", icon: "ph-database ph-bold ph-lg",
text: i18n.ts.database, text: i18n.ts.database,

View file

@ -1,91 +0,0 @@
<template>
<MkStickyContainer>
<template #header
><MkPageHeader
:actions="headerActions"
:tabs="headerTabs"
:display-back-button="true"
/></template>
<MkSpacer :content-max="700" :margin-min="16" :margin-max="32">
<FormSuspense :p="init">
<MkInfo class="_formBlock">{{
i18n.ts.proxyAccountDescription
}}</MkInfo>
<MkKeyValue class="_formBlock">
<template #key>{{ i18n.ts.proxyAccount }}</template>
<template #value>{{
proxyAccount
? `@${proxyAccount.username}`
: i18n.ts.none
}}</template>
</MkKeyValue>
<MkButton
primary
class="_formBlock"
@click="chooseProxyAccount"
>{{ i18n.ts.selectAccount }}</MkButton
>
<MkButton danger class="_formBlock" @click="del">{{
i18n.ts.remove
}}</MkButton>
</FormSuspense>
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import {} from "vue";
import MkKeyValue from "@/components/MkKeyValue.vue";
import MkButton from "@/components/MkButton.vue";
import MkInfo from "@/components/MkInfo.vue";
import FormSuspense from "@/components/form/suspense.vue";
import * as os from "@/os";
import { fetchInstance } from "@/instance";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
let proxyAccount: any = $ref(null);
let proxyAccountId: any = $ref(null);
async function init() {
const meta = await os.api("admin/meta");
proxyAccountId = meta.proxyAccountId;
if (proxyAccountId) {
proxyAccount = await os.api("users/show", { userId: proxyAccountId });
}
}
function chooseProxyAccount() {
os.selectLocalUser().then((user) => {
proxyAccount = user;
proxyAccountId = user.id;
save();
});
}
function save() {
os.apiWithDialog("admin/update-meta", {
proxyAccountId: proxyAccountId,
}).then(() => {
fetchInstance();
});
}
function del() {
os.apiWithDialog("admin/update-meta", {
proxyAccountId: null,
}).then(() => {
fetchInstance();
});
}
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.proxyAccount,
icon: "ph-ghost ph-bold ph-lg",
});
</script>

View file

@ -529,11 +529,6 @@ export const routes = [
name: "instance-block", name: "instance-block",
component: page(() => import("./pages/admin/instance-block.vue")), 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", path: "/other-settings",
name: "other-settings", name: "other-settings",