mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 00:43:49 +01:00
[backend] Remove user list proxy account
This commit is contained in:
parent
ed25373bc7
commit
7ad6bbd32c
@ -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<void> {
|
||||
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<void> {
|
||||
|
@ -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`);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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,
|
||||
})
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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",
|
||||
},
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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>
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user