Skip to content

Commit

Permalink
Revert "feat: サーバーサイレンス機能を追加 (misskey-dev#12031)"
Browse files Browse the repository at this point in the history
This reverts commit 5efd01b.
  • Loading branch information
ZerglingGo committed Nov 14, 2023
1 parent 81aec10 commit 0b3a6c2
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 178 deletions.
7 changes: 2 additions & 5 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ perHour: "Per Hour"
perDay: "Per Day"
stopActivityDelivery: "Stop sending activities"
blockThisInstance: "Block this instance"
silenceThisInstance: "Silence this instance"
operations: "Operations"
software: "Software"
version: "Version"
Expand All @@ -214,9 +213,7 @@ clearQueueConfirmText: "Any undelivered notes remaining in the queue will not be
clearCachedFiles: "Clear cache"
clearCachedFilesConfirm: "Are you sure that you want to delete all cached remote files?"
blockedInstances: "Blocked Instances"
blockedInstancesDescription: "List the hostnames of the instances you want to block separated by linebreaks. Listed instances will no longer be able to communicate with this instance."
silencedInstances: "Silenced instances"
silencedInstancesDescription: "List the hostnames of the instances that you want to silence. All accounts of the listed instances will be treated as silenced, can only make follow requests, and cannot mention local accounts if not followed. This will not affect blocked instances."
blockedInstancesDescription: "List the hostnames of the instances that you want to block separated by linebreaks. Listed instances will no longer be able to communicate with this instance."
muteAndBlock: "Mutes and Blocks"
mutedUsers: "Muted users"
blockedUsers: "Blocked users"
Expand Down Expand Up @@ -798,7 +795,7 @@ active: "Active"
offline: "Offline"
notRecommended: "Not recommended"
botProtection: "Bot Protection"
instanceBlocking: "Blocked/Silenced Instances"
instanceBlocking: "Blocked Instances"
selectAccount: "Select account"
switchAccount: "Switch account"
enabled: "Enabled"
Expand Down
2 changes: 0 additions & 2 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ export interface Locale {
"clearCachedFilesConfirm": string;
"blockedInstances": string;
"blockedInstancesDescription": string;
"silencedInstances": string;
"silencedInstancesDescription": string;
"muteAndBlock": string;
"mutedUsers": string;
"blockedUsers": string;
Expand Down
7 changes: 2 additions & 5 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ perDay: "1日ごと"
silenceThisInstance: "このサーバーをサイレンス"
stopActivityDelivery: "アクティビティの配送を停止"
blockThisInstance: "このサーバーをブロック"
silenceThisInstance: "サーバーをサイレンス"
operations: "操作"
software: "ソフトウェア"
version: "バージョン"
Expand All @@ -217,9 +216,7 @@ clearQueueConfirmText: "未配達の投稿は配送されなくなります。
clearCachedFiles: "キャッシュをクリア"
clearCachedFilesConfirm: "キャッシュされたリモートファイルをすべて削除しますか?"
blockedInstances: "ブロックしたサーバー"
blockedInstancesDescription: "ブロックしたいサーバーのホストを改行で区切って設定します。ブロックされたサーバーは、このインスタンスとやり取りできなくなります。"
silencedInstances: "サイレンスしたサーバー"
silencedInstancesDescription: "サイレンスしたいサーバーのホストを改行で区切って設定します。サイレンスされたサーバーに所属するアカウントはすべて「サイレンス」として扱われ、フォローがすべてリクエストになり、フォロワーでないローカルアカウントにはメンションできなくなります。ブロックしたインスタンスには影響しません。"
blockedInstancesDescription: "ブロックしたいサーバーのホストを改行で区切って設定します。ブロックされたサーバーは、このサーバーとやり取りできなくなります。サブドメインもブロックされます。"
muteAndBlock: "ミュートとブロック"
mutedUsers: "ミュートしたユーザー"
blockedUsers: "ブロックしたユーザー"
Expand Down Expand Up @@ -802,7 +799,7 @@ active: "アクティブ"
offline: "オフライン"
notRecommended: "非推奨"
botProtection: "Botプロテクション"
instanceBlocking: "サーバーブロック・サイレンス"
instanceBlocking: "サーバーブロック"
selectAccount: "アカウントを選択"
switchAccount: "アカウントを切り替え"
enabled: "有効"
Expand Down
16 changes: 0 additions & 16 deletions packages/backend/migration/1697247230117-InstanceSilence.js

This file was deleted.

8 changes: 0 additions & 8 deletions packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import { MetaService } from '@/core/MetaService.js';
import { SearchService } from '@/core/SearchService.js';
import { FeaturedService } from '@/core/FeaturedService.js';
import { FunoutTimelineService } from '@/core/FunoutTimelineService.js';
import { UtilityService } from '@/core/UtilityService.js';
import { UserBlockingService } from '@/core/UserBlockingService.js';

type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
Expand Down Expand Up @@ -215,7 +214,6 @@ export class NoteCreateService implements OnApplicationShutdown {
private perUserNotesChart: PerUserNotesChart,
private activeUsersChart: ActiveUsersChart,
private instanceChart: InstanceChart,
private utilityService: UtilityService,
private userBlockingService: UserBlockingService,
) { }

Expand Down Expand Up @@ -269,12 +267,6 @@ export class NoteCreateService implements OnApplicationShutdown {
}
}

const inSilencedInstance = this.utilityService.isSilencedHost(meta.silencedHosts, user.host);

if (data.visibility === 'public' && inSilencedInstance && user.host !== null) {
data.visibility = 'home';
}

if (data.renote) {
switch (data.renote.visibility) {
case 'public':
Expand Down
11 changes: 4 additions & 7 deletions packages/backend/src/core/UserFollowingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
import { Inject, Injectable, OnModuleInit, forwardRef } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { IsNull } from 'typeorm';
import type { MiLocalUser, MiPartialLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js';
Expand All @@ -28,7 +28,6 @@ import { MetaService } from '@/core/MetaService.js';
import { CacheService } from '@/core/CacheService.js';
import type { Config } from '@/config.js';
import { AccountMoveService } from '@/core/AccountMoveService.js';
import { UtilityService } from '@/core/UtilityService.js';
import { FunoutTimelineService } from '@/core/FunoutTimelineService.js';
import Logger from '../logger.js';

Expand Down Expand Up @@ -73,7 +72,6 @@ export class UserFollowingService implements OnModuleInit {
private instancesRepository: InstancesRepository,

private cacheService: CacheService,
private utilityService: UtilityService,
private userEntityService: UserEntityService,
private idService: IdService,
private queueService: QueueService,
Expand Down Expand Up @@ -130,16 +128,15 @@ export class UserFollowingService implements OnModuleInit {
}

const followeeProfile = await this.userProfilesRepository.findOneByOrFail({ userId: followee.id });

// フォロー対象が鍵アカウントである or
// フォロワーがBotであり、フォロー対象がBotからのフォローに慎重である or
// フォロワーがローカルユーザーであり、フォロー対象がリモートユーザーである or
// フォロワーがローカルユーザーであり、フォロー対象がサイレンスされているサーバーである
// フォロワーがローカルユーザーであり、フォロー対象がリモートユーザーである
// 上記のいずれかに当てはまる場合はすぐフォローせずにフォローリクエストを発行しておく
if (
followee.isLocked ||
(followeeProfile.carefulBot && follower.isBot) ||
(this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee) && process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING !== 'true') ||
(this.userEntityService.isLocalUser(followee) && this.userEntityService.isRemoteUser(follower) && this.utilityService.isSilencedHost((await this.metaService.fetch()).silencedHosts, follower.host))
(this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee) && process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING !== 'true')
) {
let autoAccept = false;

Expand Down
6 changes: 0 additions & 6 deletions packages/backend/src/core/UtilityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ export class UtilityService {
return blockedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
}

@bindThis
public isSilencedHost(silencedHosts: string[] | undefined, host: string | null): boolean {
if (!silencedHosts || host == null) return false;
return silencedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
}

@bindThis
public extractDbHost(uri: string): string {
const url = new URL(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { Injectable } from '@nestjs/common';
import type { Packed } from '@/misc/json-schema.js';
import type { } from '@/models/Blocking.js';
import type { MiInstance } from '@/models/Instance.js';
import { MetaService } from '@/core/MetaService.js';
import { bindThis } from '@/decorators.js';
Expand Down Expand Up @@ -43,7 +44,6 @@ export class InstanceEntityService {
description: instance.description,
maintainerName: instance.maintainerName,
maintainerEmail: instance.maintainerEmail,
isSilenced: this.utilityService.isSilencedHost(meta.silencedHosts, instance.host),
iconUrl: instance.iconUrl,
faviconUrl: instance.faviconUrl,
themeColor: instance.themeColor,
Expand Down
5 changes: 0 additions & 5 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ export class MiMeta {
})
public sensitiveWords: string[];

@Column('varchar', {
length: 1024, array: true, default: '{}',
})
public silencedHosts: string[];

@Column('varchar', {
length: 1024,
nullable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ export const packedFederationInstanceSchema = {
type: 'string',
optional: false, nullable: true,
},
isSilenced: {
type: "boolean",
optional: false,
nullable: false,
},
infoUpdatedAt: {
type: 'string',
optional: false, nullable: true,
Expand Down
11 changes: 0 additions & 11 deletions packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ export const meta = {
type: 'boolean',
optional: false, nullable: false,
},
silencedHosts: {
type: 'array',
optional: true,
nullable: false,
items: {
type: 'string',
optional: false,
nullable: false,
},
},
pinnedUsers: {
type: 'array',
optional: false, nullable: false,
Expand Down Expand Up @@ -381,7 +371,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
pinnedUsers: instance.pinnedUsers,
hiddenTags: instance.hiddenTags,
blockedHosts: instance.blockedHosts,
silencedHosts: instance.silencedHosts,
sensitiveWords: instance.sensitiveWords,
preservedUsernames: instance.preservedUsernames,
hcaptchaSecretKey: instance.hcaptchaSecretKey,
Expand Down
56 changes: 16 additions & 40 deletions packages/backend/src/server/api/endpoints/admin/update-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,18 @@ export const paramDef = {
type: 'object',
properties: {
disableRegistration: { type: 'boolean', nullable: true },
pinnedUsers: {
type: 'array', nullable: true, items: {
type: 'string',
},
},
hiddenTags: {
type: 'array', nullable: true, items: {
type: 'string',
},
},
blockedHosts: {
type: 'array', nullable: true, items: {
type: 'string',
},
},
sensitiveWords: {
type: 'array', nullable: true, items: {
type: 'string',
},
},
pinnedUsers: { type: 'array', nullable: true, items: {
type: 'string',
} },
hiddenTags: { type: 'array', nullable: true, items: {
type: 'string',
} },
blockedHosts: { type: 'array', nullable: true, items: {
type: 'string',
} },
sensitiveWords: { type: 'array', nullable: true, items: {
type: 'string',
} },
themeColor: { type: 'string', nullable: true, pattern: '^#[0-9a-fA-F]{6}$' },
mascotImageUrl: { type: 'string', nullable: true },
bannerUrl: { type: 'string', nullable: true },
Expand Down Expand Up @@ -75,11 +67,9 @@ export const paramDef = {
proxyAccountId: { type: 'string', format: 'misskey:id', nullable: true },
maintainerName: { type: 'string', nullable: true },
maintainerEmail: { type: 'string', nullable: true },
langs: {
type: 'array', items: {
type: 'string',
},
},
langs: { type: 'array', items: {
type: 'string',
} },
summalyProxy: { type: 'string', nullable: true },
deeplAuthKey: { type: 'string', nullable: true },
deeplIsPro: { type: 'boolean' },
Expand Down Expand Up @@ -126,13 +116,6 @@ export const paramDef = {
perUserHomeTimelineCacheMax: { type: 'integer' },
perUserListTimelineCacheMax: { type: 'integer' },
notesPerOneAd: { type: 'integer' },
silencedHosts: {
type: 'array',
nullable: true,
items: {
type: 'string',
},
},
},
required: [],
} as const;
Expand Down Expand Up @@ -165,14 +148,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (Array.isArray(ps.sensitiveWords)) {
set.sensitiveWords = ps.sensitiveWords.filter(Boolean);
}
if (Array.isArray(ps.silencedHosts)) {
let lastValue = '';
set.silencedHosts = ps.silencedHosts.sort().filter((h) => {
const lv = lastValue;
lastValue = h;
return h !== '' && h !== lv && !set.blockedHosts?.includes(h);
});
}

if (ps.themeColor !== undefined) {
set.themeColor = ps.themeColor;
}
Expand Down
18 changes: 0 additions & 18 deletions packages/backend/src/server/api/endpoints/federation/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const paramDef = {
notResponding: { type: 'boolean', nullable: true },
silenced: { type: 'boolean', nullable: true },
suspended: { type: 'boolean', nullable: true },
silenced: { type: "boolean", nullable: true },
federating: { type: 'boolean', nullable: true },
subscribing: { type: 'boolean', nullable: true },
publishing: { type: 'boolean', nullable: true },
Expand Down Expand Up @@ -112,23 +111,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
}

if (typeof ps.silenced === "boolean") {
const meta = await this.metaService.fetch(true);

if (ps.silenced) {
if (meta.silencedHosts.length === 0) {
return [];
}
query.andWhere("instance.host IN (:...silences)", {
silences: meta.silencedHosts,
});
} else if (meta.silencedHosts.length > 0) {
query.andWhere("instance.host NOT IN (:...silences)", {
silences: meta.silencedHosts,
});
}
}

if (typeof ps.federating === 'boolean') {
if (ps.federating) {
query.andWhere('((instance.followingCount > 0) OR (instance.followersCount > 0))');
Expand Down
6 changes: 0 additions & 6 deletions packages/frontend/src/components/MkInstanceCardMini.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ function getInstanceIcon(instance): string {
height: 30px;
}

&:global(.blue) {
--c: rgba(0, 42, 255, 0.15);
background-image: linear-gradient(45deg, var(--c) 16.67%, transparent 16.67%, transparent 50%, var(--c) 50%, var(--c) 66.67%, transparent 66.67%, transparent 100%);
background-size: 16px 16px;
}

&:global(.yellow) {
--c: rgb(255 196 0 / 15%);
background-image: linear-gradient(45deg, var(--c) 16.67%, transparent 16.67%, transparent 50%, var(--c) 50%, var(--c) 66.67%, transparent 66.67%, transparent 100%);
Expand Down
3 changes: 0 additions & 3 deletions packages/frontend/src/pages/about.federation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="subscribing">{{ i18n.ts.subscribing }}</option>
<option value="publishing">{{ i18n.ts.publishing }}</option>
<option value="suspended">{{ i18n.ts.suspended }}</option>
<option value="silenced">{{ i18n.ts.silence }}</option>
<option value="blocked">{{ i18n.ts.blocked }}</option>
<option value="notResponding">{{ i18n.ts.notResponding }}</option>
</MkSelect>
Expand Down Expand Up @@ -76,7 +75,6 @@ const pagination = {
state === 'publishing' ? { publishing: true } :
state === 'suspended' ? { suspended: true } :
state === 'blocked' ? { blocked: true } :
state === 'silenced' ? { silenced: true } :
state === 'notResponding' ? { notResponding: true } :
{}),
})),
Expand All @@ -85,7 +83,6 @@ const pagination = {
function getStatus(instance) {
if (instance.isSuspended) return 'Suspended';
if (instance.isBlocked) return 'Blocked';
if (instance.isSilenced) return 'Silenced';
if (instance.isNotResponding) return 'Error';
return 'Alive';
}
Expand Down
Loading

0 comments on commit 0b3a6c2

Please sign in to comment.