From 99a0f756ff731d136bf1bc22262911511579187a Mon Sep 17 00:00:00 2001 From: PrivateGER Date: Sat, 5 Oct 2024 18:02:38 +0200 Subject: [PATCH 1/5] Expose instance-moderation endpoints in UI --- locales/en-US.yml | 2 ++ locales/index.d.ts | 20 +++++++---- locales/ja-JP.yml | 2 ++ packages/frontend/src/pages/instance-info.vue | 33 +++++++++++++++++++ 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 221ade4028..ad517b888f 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1330,6 +1330,8 @@ confirmWhenRevealingSensitiveMedia: "Confirm when revealing sensitive media" sensitiveMediaRevealConfirm: "This media might be sensitive. Are you sure you want to reveal it?" createdLists: "Created lists" createdAntennas: "Created antennas" +severAllFollowRelations: "Break follow relationships" +severAllFollowRelationsConfirm: "Really break all follow relationships? This is irreversible!" _delivery: status: "Delivery status" stop: "Suspend delivery" diff --git a/locales/index.d.ts b/locales/index.d.ts index f93ef14325..517a7bf87d 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -3128,6 +3128,10 @@ export interface Locale extends ILocale { * 返信にサーバー情報を表示する */ "showTickerOnReplies": string; + /** + * 猫の話し方を無効にする + */ + "disableCatSpeak": string; /** * 検索MFMの検索エンジン */ @@ -4429,10 +4433,6 @@ export interface Locale extends ILocale { * 連合なしにする */ "disableFederationOk": string; - /** - * 猫の話し方を無効にする - */ - "disableCatSpeak": string; /** * 現在このサーバーは招待制です。招待コードをお持ちの方のみ登録できます。 */ @@ -5337,6 +5337,14 @@ export interface Locale extends ILocale { * 作成したアンテナ */ "createdAntennas": string; + /** + * 以下の関係をすべて断ち切る + */ + "severAllFollowRelations": string; + /** + * 本当にすべての関係を断ち切りたいのですか?これは不可逆的だ。 + */ + "severAllFollowRelationsConfirm": string; "_delivery": { /** * 配信状態 @@ -5777,7 +5785,7 @@ export interface Locale extends ILocale { */ "social": string; /** - * バッッブルタイムラインでは、管理者が選択した接続サーバーからのメモを表示できます。 + * バブルタイムラインでは、管理者が選択した接続サーバーからの投稿を表示できます。 */ "bubble": string; /** @@ -9139,7 +9147,7 @@ export interface Locale extends ILocale { */ "global": string; /** - * バッッブル + * バブル */ "bubble": string; }; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 70acc3adf4..5aec622638 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1330,6 +1330,8 @@ confirmWhenRevealingSensitiveMedia: "センシティブなメディアを表示 sensitiveMediaRevealConfirm: "センシティブなメディアです。表示しますか?" createdLists: "作成したリスト" createdAntennas: "作成したアンテナ" +severAllFollowRelations: "以下の関係をすべて断ち切る" +severAllFollowRelationsConfirm: "本当にすべての関係を断ち切りたいのですか?これは不可逆的だ。" _delivery: status: "配信状態" diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 4ff26197d8..18dfa80d6b 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -43,6 +43,8 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts._delivery._type[suspensionState] }} + {{ i18n.ts.deleteAllFilesConfirm }} + {{ i18n.ts.severAllFollowRelations }} {{ i18n.ts._delivery.stop }} {{ i18n.ts._delivery.resume }} {{ i18n.ts.blockThisInstance }} @@ -270,6 +272,37 @@ function refreshMetadata(): void { }); } +async function deleteAllFiles(): void { + const confirm = await os.confirm({ + type: 'danger', + text: i18n.ts.deleteAllFilesConfirm, + }); + if (!confirm) return; + if (!instance.value) throw new Error('No instance?'); + await misskeyApi('admin/federation/delete-all-files', { + host: instance.value.host, + }); + await os.alert({ + text: 'Deletion of all files queued', + }); +} + +async function severAllFollowRelations(): void { + if (!instance.value) throw new Error('No instance?'); + + const confirm = await os.confirm({ + type: 'danger', + text: i18n.ts.severAllFollowRelationsConfirm, + }); + if (!confirm) return; + await misskeyApi('admin/federation/remove-all-following', { + host: instance.value.host, + }); + await os.alert({ + text: 'Severing all follow relations queued', + }); +} + fetch(); const headerActions = computed(() => [{ From b3f925c426b88432f9b6143f05d4989a8178f3ea Mon Sep 17 00:00:00 2001 From: PrivateGER Date: Sat, 5 Oct 2024 18:50:42 +0200 Subject: [PATCH 2/5] Fix breaking follow relationships + add warning counts to dialogue --- locales/en-US.yml | 2 +- .../admin/federation/remove-all-following.ts | 2 +- packages/frontend/src/pages/instance-info.vue | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index ad517b888f..eebda35a5e 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1330,7 +1330,7 @@ confirmWhenRevealingSensitiveMedia: "Confirm when revealing sensitive media" sensitiveMediaRevealConfirm: "This media might be sensitive. Are you sure you want to reveal it?" createdLists: "Created lists" createdAntennas: "Created antennas" -severAllFollowRelations: "Break follow relationships" +severAllFollowRelations: "Break following relationships" severAllFollowRelationsConfirm: "Really break all follow relationships? This is irreversible!" _delivery: status: "Delivery status" diff --git a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts index 9e93310746..7f84e7694d 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts @@ -31,7 +31,7 @@ export default class extends Endpoint { // eslint- @Inject(DI.usersRepository) private usersRepository: UsersRepository, - @Inject(DI.notesRepository) + @Inject(DI.followingsRepository) private followingsRepository: FollowingsRepository, private queueService: QueueService, diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 18dfa80d6b..6f3fc34dd1 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -43,9 +43,11 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts._delivery._type[suspensionState] }} - {{ i18n.ts.deleteAllFilesConfirm }} - {{ i18n.ts.severAllFollowRelations }} - {{ i18n.ts._delivery.stop }} +
+ {{ i18n.ts.deleteAllFiles }} + {{ i18n.ts.severAllFollowRelations }} + {{ i18n.ts._delivery.stop }} +
{{ i18n.ts._delivery.resume }} {{ i18n.ts.blockThisInstance }} {{ i18n.ts.silenceThisInstance }} @@ -277,7 +279,8 @@ async function deleteAllFiles(): void { type: 'danger', text: i18n.ts.deleteAllFilesConfirm, }); - if (!confirm) return; + if (confirm.canceled) return; + if (!instance.value) throw new Error('No instance?'); await misskeyApi('admin/federation/delete-all-files', { host: instance.value.host, @@ -292,9 +295,10 @@ async function severAllFollowRelations(): void { const confirm = await os.confirm({ type: 'danger', - text: i18n.ts.severAllFollowRelationsConfirm, + text: `${i18n.ts.severAllFollowRelationsConfirm} This will break ${instance.value.followingCount} following and ${instance.value.followersCount} follower relations on ${meta.value.name}.`, }); - if (!confirm) return; + if (confirm.canceled) return; + await misskeyApi('admin/federation/remove-all-following', { host: instance.value.host, }); From 996d0794764332b511419e06e8c75df1cc93907b Mon Sep 17 00:00:00 2001 From: PrivateGER Date: Sat, 5 Oct 2024 19:58:58 +0200 Subject: [PATCH 3/5] Make remove-all-following remove follows in both directions --- .../admin/federation/remove-all-following.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts index 7f84e7694d..601c898f52 100644 --- a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts +++ b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts @@ -37,9 +37,14 @@ export default class extends Endpoint { // eslint- private queueService: QueueService, ) { super(meta, paramDef, async (ps, me) => { - const followings = await this.followingsRepository.findBy({ - followerHost: ps.host, - }); + const followings = await this.followingsRepository.findBy([ + { + followeeHost: ps.host, + }, + { + followerHost: ps.host, + }, + ]); const pairs = await Promise.all(followings.map(f => Promise.all([ this.usersRepository.findOneByOrFail({ id: f.followerId }), From 941a200f35d8b6ce6e8e9ea1c8207311b99f0f83 Mon Sep 17 00:00:00 2001 From: PrivateGER Date: Sun, 6 Oct 2024 19:53:10 +0200 Subject: [PATCH 4/5] Move button into button group --- packages/frontend/src/pages/instance-info.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 6f3fc34dd1..54ccd8a66b 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -47,8 +47,8 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.deleteAllFiles }} {{ i18n.ts.severAllFollowRelations }} {{ i18n.ts._delivery.stop }} + {{ i18n.ts._delivery.resume }} - {{ i18n.ts._delivery.resume }} {{ i18n.ts.blockThisInstance }} {{ i18n.ts.silenceThisInstance }} Mark as NSFW From f0287954839992c0b02f0db072fd9e93ae7695ac Mon Sep 17 00:00:00 2001 From: PrivateGER Date: Sun, 6 Oct 2024 20:31:41 +0200 Subject: [PATCH 5/5] Move text into translation files --- locales/en-US.yml | 5 ++++- locales/index.d.ts | 12 ++++++++++-- locales/ja-JP.yml | 4 +++- packages/frontend/src/pages/instance-info.vue | 10 +++++++--- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index eebda35a5e..9e111fa680 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -621,6 +621,7 @@ unsetUserBanner: "Unset banner" unsetUserBannerConfirm: "Are you sure you want to unset the banner?" deleteAllFiles: "Delete all files" deleteAllFilesConfirm: "Are you sure that you want to delete all files?" +deleteAllFilesQueued: "Deletion of all files queued" removeAllFollowing: "Unfollow all followed users" removeAllFollowingDescription: "Executing this unfollows all accounts from {host}. Please run this if the instance e.g. no longer exists." userSuspended: "This user has been suspended." @@ -1331,7 +1332,9 @@ sensitiveMediaRevealConfirm: "This media might be sensitive. Are you sure you wa createdLists: "Created lists" createdAntennas: "Created antennas" severAllFollowRelations: "Break following relationships" -severAllFollowRelationsConfirm: "Really break all follow relationships? This is irreversible!" +severAllFollowRelationsConfirm: "Really break all follow relationships? This is irreversible! This will break {followingCount} following and {followersCount} follower relations on {instanceName}!" +severAllFollowRelationsQueued: "Severing all follow relations with {host} queued." + _delivery: status: "Delivery status" stop: "Suspend delivery" diff --git a/locales/index.d.ts b/locales/index.d.ts index 517a7bf87d..b3d56d31b3 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -2500,6 +2500,10 @@ export interface Locale extends ILocale { * すべてのファイルを削除しますか? */ "deleteAllFilesConfirm": string; + /** + * キューに入れられたすべてのファイルの削除 + */ + "deleteAllFilesQueued": string; /** * フォローを全解除 */ @@ -5342,9 +5346,13 @@ export interface Locale extends ILocale { */ "severAllFollowRelations": string; /** - * 本当にすべての関係を断ち切りたいのですか?これは不可逆的だ。 + * すべての人間関係を壊す?これは不可逆です!これは{instanceName}の{followingCount}フォローと{followersCount}フォロワーの関係を壊す! */ - "severAllFollowRelationsConfirm": string; + "severAllFollowRelationsConfirm": ParameterizedString<"instanceName" | "followingCount" | "followersCount">; + /** + * キューに入れられた{host}とのすべてのフォロー関係を切断する。 + */ + "severAllFollowRelationsQueued": ParameterizedString<"host">; "_delivery": { /** * 配信状態 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 5aec622638..b37641cc4f 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -621,6 +621,7 @@ unsetUserBanner: "バナーを解除" unsetUserBannerConfirm: "バナーを解除しますか?" deleteAllFiles: "すべてのファイルを削除" deleteAllFilesConfirm: "すべてのファイルを削除しますか?" +deleteAllFilesQueued: "キューに入れられたすべてのファイルの削除" removeAllFollowing: "フォローを全解除" removeAllFollowingDescription: "{host}からのフォローをすべて解除します。そのサーバーがもう存在しなくなった場合などに実行してください。" userSuspended: "このユーザーは凍結されています。" @@ -1331,7 +1332,8 @@ sensitiveMediaRevealConfirm: "センシティブなメディアです。表示 createdLists: "作成したリスト" createdAntennas: "作成したアンテナ" severAllFollowRelations: "以下の関係をすべて断ち切る" -severAllFollowRelationsConfirm: "本当にすべての関係を断ち切りたいのですか?これは不可逆的だ。" +severAllFollowRelationsConfirm: "すべての人間関係を壊す?これは不可逆です!これは{instanceName}の{followingCount}フォローと{followersCount}フォロワーの関係を壊す!" +severAllFollowRelationsQueued: "キューに入れられた{host}とのすべてのフォロー関係を切断する。" _delivery: status: "配信状態" diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 54ccd8a66b..28ad2da0a7 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -286,7 +286,7 @@ async function deleteAllFiles(): void { host: instance.value.host, }); await os.alert({ - text: 'Deletion of all files queued', + text: i18n.ts.deleteAllFilesQueued, }); } @@ -295,7 +295,11 @@ async function severAllFollowRelations(): void { const confirm = await os.confirm({ type: 'danger', - text: `${i18n.ts.severAllFollowRelationsConfirm} This will break ${instance.value.followingCount} following and ${instance.value.followersCount} follower relations on ${meta.value.name}.`, + text: i18n.tsx.severAllFollowRelationsConfirm({ + instanceName: meta.value.shortName ?? meta.value.name, + followingCount: instance.value.followingCount, + followersCount: instance.value.followersCount, + }), }); if (confirm.canceled) return; @@ -303,7 +307,7 @@ async function severAllFollowRelations(): void { host: instance.value.host, }); await os.alert({ - text: 'Severing all follow relations queued', + text: i18n.tsx.severAllFollowRelationsQueued({ host: instance.value.host }), }); }