feat: media silence
This commit is contained in:
parent
acf84a2516
commit
a5babaffc9
|
@ -824,6 +824,10 @@ export interface Locale extends ILocale {
|
|||
* サーバーをサイレンス
|
||||
*/
|
||||
"silenceThisInstance": string;
|
||||
/**
|
||||
* サーバーをメディアサイレンス
|
||||
*/
|
||||
"mediaSilenceThisInstance": string;
|
||||
/**
|
||||
* 操作
|
||||
*/
|
||||
|
@ -908,6 +912,14 @@ export interface Locale extends ILocale {
|
|||
* サイレンスしたいサーバーのホストを改行で区切って設定します。サイレンスされたサーバーに所属するアカウントはすべて「サイレンス」として扱われ、フォローがすべてリクエストになり、フォロワーでないローカルアカウントにはメンションできなくなります。ブロックしたインスタンスには影響しません。
|
||||
*/
|
||||
"silencedInstancesDescription": string;
|
||||
/**
|
||||
* メディアサイレンスしたサーバー
|
||||
*/
|
||||
"mediaSilencedInstances": string;
|
||||
/**
|
||||
* メディアサイレンスしたいサーバーのホストを改行で区切って設定します。メディアサイレンスされたサーバーに所属するアカウントによるファイルすべてセンシティブとして扱われるようになります。ブロックしたインスタンスには影響しません。
|
||||
*/
|
||||
"mediaSilencedInstancesDescription": string;
|
||||
/**
|
||||
* ミュートとブロック
|
||||
*/
|
||||
|
|
|
@ -202,6 +202,7 @@ perDay: "1日ごと"
|
|||
stopActivityDelivery: "アクティビティの配送を停止"
|
||||
blockThisInstance: "このサーバーをブロック"
|
||||
silenceThisInstance: "サーバーをサイレンス"
|
||||
mediaSilenceThisInstance: "サーバーをメディアサイレンス"
|
||||
operations: "操作"
|
||||
software: "ソフトウェア"
|
||||
version: "バージョン"
|
||||
|
@ -223,6 +224,8 @@ blockedInstances: "ブロックしたサーバー"
|
|||
blockedInstancesDescription: "ブロックしたいサーバーのホストを改行で区切って設定します。ブロックされたサーバーは、このインスタンスとやり取りできなくなります。"
|
||||
silencedInstances: "サイレンスしたサーバー"
|
||||
silencedInstancesDescription: "サイレンスしたいサーバーのホストを改行で区切って設定します。サイレンスされたサーバーに所属するアカウントはすべて「サイレンス」として扱われ、フォローがすべてリクエストになり、フォロワーでないローカルアカウントにはメンションできなくなります。ブロックしたインスタンスには影響しません。"
|
||||
mediaSilencedInstances: "メディアサイレンスしたサーバー"
|
||||
mediaSilencedInstancesDescription: "メディアサイレンスしたいサーバーのホストを改行で区切って設定します。メディアサイレンスされたサーバーに所属するアカウントによるファイルすべてセンシティブとして扱われるようになります。ブロックしたインスタンスには影響しません。"
|
||||
muteAndBlock: "ミュートとブロック"
|
||||
mutedUsers: "ミュートしたユーザー"
|
||||
blockedUsers: "ブロックしたユーザー"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class MediaSilenceForHosts1716197366117 {
|
||||
name = 'MediaSilenceForHosts1716197366117'
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "meta" ADD "mediaSilencedHosts" character varying(1024) array NOT NULL DEFAULT '{}'`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "mediaSilencedHosts"`);
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ import { RoleService } from '@/core/RoleService.js';
|
|||
import { correctFilename } from '@/misc/correct-filename.js';
|
||||
import { isMimeImage } from '@/misc/is-mime-image.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
import {UtilityService} from "@/core/UtilityService.js";
|
||||
|
||||
type AddFileArgs = {
|
||||
/** User who wish to add file */
|
||||
|
@ -127,6 +128,7 @@ export class DriveService {
|
|||
private driveChart: DriveChart,
|
||||
private perUserDriveChart: PerUserDriveChart,
|
||||
private instanceChart: InstanceChart,
|
||||
private utilityService: UtilityService,
|
||||
) {
|
||||
const logger = new Logger('drive', 'blue');
|
||||
this.registerLogger = logger.createSubLogger('register', 'yellow');
|
||||
|
@ -581,6 +583,7 @@ export class DriveService {
|
|||
sensitive ?? false
|
||||
: false;
|
||||
|
||||
if (user && this.utilityService.isMediaSilencedHost(instance.mediaSilencedHosts, user.host)) file.isSensitive = true;
|
||||
if (info.sensitive && profile!.autoSensitive) file.isSensitive = true;
|
||||
if (info.sensitive && instance.setSensitiveFlagAutomatically) file.isSensitive = true;
|
||||
if (userRoleNSFW) file.isSensitive = true;
|
||||
|
|
|
@ -42,6 +42,12 @@ export class UtilityService {
|
|||
return silencedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public isMediaSilencedHost(silencedHosts: string[] | undefined, host: string | null): boolean {
|
||||
if (!silencedHosts || host == null) return false;
|
||||
return silencedHosts.some(x => host.toLowerCase() === x);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public concatNoteContentsForKeyWordCheck(content: {
|
||||
cw?: string | null;
|
||||
|
|
|
@ -49,6 +49,7 @@ export class InstanceEntityService {
|
|||
maintainerName: instance.maintainerName,
|
||||
maintainerEmail: instance.maintainerEmail,
|
||||
isSilenced: this.utilityService.isSilencedHost(meta.silencedHosts, instance.host),
|
||||
isMediaSilenced: this.utilityService.isMediaSilencedHost(meta.mediaSilencedHosts, instance.host),
|
||||
iconUrl: instance.iconUrl,
|
||||
faviconUrl: instance.faviconUrl,
|
||||
themeColor: instance.themeColor,
|
||||
|
|
|
@ -86,6 +86,11 @@ export class MiMeta {
|
|||
})
|
||||
public silencedHosts: string[];
|
||||
|
||||
@Column('varchar', {
|
||||
length: 1024, array: true, default: '{}',
|
||||
})
|
||||
public mediaSilencedHosts: string[];
|
||||
|
||||
@Column('varchar', {
|
||||
length: 1024,
|
||||
nullable: true,
|
||||
|
|
|
@ -83,6 +83,10 @@ export const packedFederationInstanceSchema = {
|
|||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
isMediaSilenced: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
iconUrl: {
|
||||
type: 'string',
|
||||
optional: false, nullable: true,
|
||||
|
|
|
@ -128,6 +128,16 @@ export const meta = {
|
|||
nullable: false,
|
||||
},
|
||||
},
|
||||
mediaSilencedHosts: {
|
||||
type: 'array',
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: 'string',
|
||||
optional: false,
|
||||
nullable: false,
|
||||
},
|
||||
},
|
||||
pinnedUsers: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
|
@ -547,6 +557,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
hiddenTags: instance.hiddenTags,
|
||||
blockedHosts: instance.blockedHosts,
|
||||
silencedHosts: instance.silencedHosts,
|
||||
mediaSilencedHosts: instance.mediaSilencedHosts,
|
||||
sensitiveWords: instance.sensitiveWords,
|
||||
prohibitedWords: instance.prohibitedWords,
|
||||
preservedUsernames: instance.preservedUsernames,
|
||||
|
|
|
@ -149,6 +149,13 @@ export const paramDef = {
|
|||
type: 'string',
|
||||
},
|
||||
},
|
||||
mediaSilencedHosts: {
|
||||
type: 'array',
|
||||
nullable: true,
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
summalyProxy: {
|
||||
type: 'string', nullable: true,
|
||||
description: '[Deprecated] Use "urlPreviewSummaryProxyUrl" instead.',
|
||||
|
@ -202,6 +209,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
return h !== '' && h !== lv && !set.blockedHosts?.includes(h);
|
||||
});
|
||||
}
|
||||
if (Array.isArray(ps.mediaSilencedHosts)) {
|
||||
let lastValue = '';
|
||||
set.mediaSilencedHosts = ps.mediaSilencedHosts.sort().filter((h) => {
|
||||
const lv = lastValue;
|
||||
lastValue = h;
|
||||
return h !== '' && h !== lv && !set.blockedHosts?.includes(h);
|
||||
});
|
||||
}
|
||||
if (ps.themeColor !== undefined) {
|
||||
set.themeColor = ps.themeColor;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<span>{{ i18n.ts.silencedInstances }}</span>
|
||||
<template #caption>{{ i18n.ts.silencedInstancesDescription }}</template>
|
||||
</MkTextarea>
|
||||
<MkTextarea v-else-if="tab === 'silence'" v-model="mediaSilencedHosts" class="_formBlock">
|
||||
<span>{{ i18n.ts.mediaSilencedInstances }}</span>
|
||||
<template #caption>{{ i18n.ts.silencedInstancesDescription }}</template>
|
||||
</MkTextarea>
|
||||
<MkButton primary @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
||||
</FormSuspense>
|
||||
</MkSpacer>
|
||||
|
@ -36,18 +40,21 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|||
|
||||
const blockedHosts = ref<string>('');
|
||||
const silencedHosts = ref<string>('');
|
||||
const mediaSilencedHosts = ref<string>('');
|
||||
const tab = ref('block');
|
||||
|
||||
async function init() {
|
||||
const meta = await misskeyApi('admin/meta');
|
||||
blockedHosts.value = meta.blockedHosts.join('\n');
|
||||
silencedHosts.value = meta.silencedHosts.join('\n');
|
||||
mediaSilencedHosts.value = meta.mediaSilencedHosts.join('\n');
|
||||
}
|
||||
|
||||
function save() {
|
||||
os.apiWithDialog('admin/update-meta', {
|
||||
blockedHosts: blockedHosts.value.split('\n') || [],
|
||||
silencedHosts: silencedHosts.value.split('\n') || [],
|
||||
mediaSilencedHosts: mediaSilencedHosts.value.split('\n') || [],
|
||||
|
||||
}).then(() => {
|
||||
fetchInstance(true);
|
||||
|
|
|
@ -38,6 +38,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkSwitch v-model="suspended" :disabled="!instance" @update:modelValue="toggleSuspend">{{ i18n.ts.stopActivityDelivery }}</MkSwitch>
|
||||
<MkSwitch v-model="isBlocked" :disabled="!meta || !instance" @update:modelValue="toggleBlock">{{ i18n.ts.blockThisInstance }}</MkSwitch>
|
||||
<MkSwitch v-model="isSilenced" :disabled="!meta || !instance" @update:modelValue="toggleSilenced">{{ i18n.ts.silenceThisInstance }}</MkSwitch>
|
||||
<MkSwitch v-model="isMediaSilenced" :disabled="!meta || !instance" @update:modelValue="toggleMediaSilenced">{{ i18n.ts.mediaSilenceThisInstance }}</MkSwitch>
|
||||
<MkButton @click="refreshMetadata"><i class="ti ti-refresh"></i> Refresh metadata</MkButton>
|
||||
<MkTextarea v-model="moderationNote" manualSave>
|
||||
<template #label>{{ i18n.ts.moderationNote }}</template>
|
||||
|
@ -158,6 +159,7 @@ const instance = ref<Misskey.entities.FederationInstance | null>(null);
|
|||
const suspended = ref(false);
|
||||
const isBlocked = ref(false);
|
||||
const isSilenced = ref(false);
|
||||
const isMediaSilenced = ref(false);
|
||||
const faviconUrl = ref<string | null>(null);
|
||||
const moderationNote = ref('');
|
||||
|
||||
|
@ -186,8 +188,9 @@ async function fetch(): Promise<void> {
|
|||
suspended.value = instance.value?.isSuspended ?? false;
|
||||
isBlocked.value = instance.value?.isBlocked ?? false;
|
||||
isSilenced.value = instance.value?.isSilenced ?? false;
|
||||
isMediaSilenced.value = instance.value?.isMediaSilenced ?? false;
|
||||
faviconUrl.value = getProxiedImageUrlNullable(instance.value?.faviconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.value?.iconUrl, 'preview');
|
||||
moderationNote.value = instance.value?.moderationNote;
|
||||
moderationNote.value = instance.value?.moderationNote ?? '';
|
||||
}
|
||||
|
||||
async function toggleBlock(): Promise<void> {
|
||||
|
@ -209,6 +212,16 @@ async function toggleSilenced(): Promise<void> {
|
|||
});
|
||||
}
|
||||
|
||||
async function toggleMediaSilenced(): Promise<void> {
|
||||
if (!meta.value) throw new Error('No meta?');
|
||||
if (!instance.value) throw new Error('No instance?');
|
||||
const { host } = instance.value;
|
||||
const mediaSilencedHosts = meta.value.mediaSilencedHosts ?? [];
|
||||
await misskeyApi('admin/update-meta', {
|
||||
mediaSilencedHosts: isMediaSilenced.value ? mediaSilencedHosts.concat([host]) : mediaSilencedHosts.filter(x => x !== host),
|
||||
});
|
||||
}
|
||||
|
||||
async function toggleSuspend(): Promise<void> {
|
||||
if (!instance.value) throw new Error('No instance?');
|
||||
await misskeyApi('admin/federation/update-instance', {
|
||||
|
|
|
@ -4486,6 +4486,7 @@ export type components = {
|
|||
maintainerName: string | null;
|
||||
maintainerEmail: string | null;
|
||||
isSilenced: boolean;
|
||||
isMediaSilenced: boolean;
|
||||
/** Format: url */
|
||||
iconUrl: string | null;
|
||||
/** Format: url */
|
||||
|
@ -4898,6 +4899,7 @@ export type operations = {
|
|||
enableServiceWorker: boolean;
|
||||
translatorAvailable: boolean;
|
||||
silencedHosts?: string[];
|
||||
mediaSilencedHosts: string[];
|
||||
pinnedUsers: string[];
|
||||
hiddenTags: string[];
|
||||
blockedHosts: string[];
|
||||
|
@ -8932,6 +8934,7 @@ export type operations = {
|
|||
perUserListTimelineCacheMax?: number;
|
||||
notesPerOneAd?: number;
|
||||
silencedHosts?: string[] | null;
|
||||
mediaSilencedHosts?: string[] | null;
|
||||
/** @description [Deprecated] Use "urlPreviewSummaryProxyUrl" instead. */
|
||||
summalyProxy?: string | null;
|
||||
urlPreviewEnabled?: boolean;
|
||||
|
|
Loading…
Reference in New Issue