From 27d43879a24b9243657af50d32d459a36b6596ec Mon Sep 17 00:00:00 2001
From: Hazelnoot <acomputerdog@gmail.com>
Date: Wed, 26 Feb 2025 23:18:30 -0500
Subject: add moderation logs for many endpoints

- `/admin/delete-all-files-of-a-user`
- `/admin/nsfw-user`
- `/admin/unnsfw-user`
- `/admin/silence-user`
- `/admin/unsilence-user`
- `/admin/accounts/create`
- `/admin/drive/clean-remote-files`
- `/admin/drive/cleanup`
- `/admin/emoji/set-category-bulk`
- `/admin/emoji/set-license-bulk`
- `/admin/emoji/set-aliases-bulk`
- `/admin/emoji/add-aliases-bulk`
- `/admin/emoji/remove-aliases-bulk`
- `/admin/emoji/import-zip`
- `/admin/federation/delete-all-files`
- `/admin/federation/remove-all-following`
- `/admin/promo/create`
- `/admin/relay/add`
- `/admin/relay/remove`
---
 .../frontend/src/pages/admin/modlog.ModLog.vue     | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)

(limited to 'packages/frontend/src/pages/admin/modlog.ModLog.vue')

diff --git a/packages/frontend/src/pages/admin/modlog.ModLog.vue b/packages/frontend/src/pages/admin/modlog.ModLog.vue
index 306a873173..a4731af47b 100644
--- a/packages/frontend/src/pages/admin/modlog.ModLog.vue
+++ b/packages/frontend/src/pages/admin/modlog.ModLog.vue
@@ -18,6 +18,10 @@ SPDX-License-Identifier: AGPL-3.0-only
 					'createAvatarDecoration',
 					'createSystemWebhook',
 					'createAbuseReportNotificationRecipient',
+					'createAccount',
+					'importCustomEmojis',
+					'createPromo',
+					'addRelay',
 				].includes(log.type),
 				[$style.logYellow]: [
 					'markSensitiveDriveFile',
@@ -30,6 +34,11 @@ SPDX-License-Identifier: AGPL-3.0-only
 					'acceptRemoteInstanceReports',
 					'rejectQuotesUser',
 					'acceptQuotesUser',
+					'nsfwUser',
+					'unNsfwUser',
+					'silenceUser',
+					'unSilenceUser',
+					'updateCustomEmojis',
 				].includes(log.type),
 				[$style.logRed]: [
 					'suspend',
@@ -49,6 +58,12 @@ SPDX-License-Identifier: AGPL-3.0-only
 					'deletePage',
 					'deleteFlash',
 					'deleteGalleryPost',
+					'clearUserFiles',
+					'clearRemoteFiles',
+					'clearOwnerlessFiles',
+					'clearInstanceFiles',
+					'severFollowRelations',
+					'removeRelay',
 				].includes(log.type)
 			}"
 		>{{ i18n.ts._moderationLogTypes[log.type] }}</b>
@@ -100,6 +115,17 @@ SPDX-License-Identifier: AGPL-3.0-only
 		<span v-else-if="log.type === 'deletePage'">: @{{ log.info.pageUserUsername }}</span>
 		<span v-else-if="log.type === 'deleteFlash'">: @{{ log.info.flashUserUsername }}</span>
 		<span v-else-if="log.type === 'deleteGalleryPost'">: @{{ log.info.postUserUsername }}</span>
+		<span v-else-if="log.type === 'clearUserFiles'">: @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</span>
+		<span v-else-if="log.type === 'nsfwUser'">: @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</span>
+		<span v-else-if="log.type === 'unNsfwUser'">: @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</span>
+		<span v-else-if="log.type === 'silenceUser'">: @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</span>
+		<span v-else-if="log.type === 'unSilenceUser'">: @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</span>
+		<span v-else-if="log.type === 'createAccount'">: @{{ log.info.userUsername }}</span>
+		<span v-else-if="log.type === 'importCustomEmojis'">: {{ log.info.fileName }}</span>
+		<span v-else-if="log.type === 'clearInstanceFiles'">: {{ log.info.host }}</span>
+		<span v-else-if="log.type === 'severFollowRelations'">: {{ log.info.host }}</span>
+		<span v-else-if="log.type === 'addRelay'">: {{ log.info.inbox }}</span>
+		<span v-else-if="log.type === 'removeRelay'">: {{ log.info.inbox }}</span>
 	</template>
 	<template v-if="log.user" #icon>
 		<MkAvatar :user="log.user" :class="$style.avatar"/>
@@ -205,6 +231,35 @@ SPDX-License-Identifier: AGPL-3.0-only
 				<CodeDiff :context="5" :hideHeader="true" :oldString="log.info.before ?? ''" :newString="log.info.after ?? ''" maxHeight="300px"/>
 			</div>
 		</template>
+		<template v-else-if="log.type === 'clearUserFiles'">
+			<div>{{ i18n.ts.user }}: <MkA :to="`/admin/user/${log.info.userId}`" class="_link">@{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</MkA></div>
+			<div>{{ i18n.ts.filesRemoved }}: {{ log.info.count }}</div>
+		</template>
+		<template v-else-if="log.type === 'nsfwUser'">
+			<div>{{ i18n.ts.user }}: <MkA :to="`/admin/user/${log.info.userId}`" class="_link">@{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</MkA></div>
+		</template>
+		<template v-else-if="log.type === 'unNsfwUser'">
+			<div>{{ i18n.ts.user }}: <MkA :to="`/admin/user/${log.info.userId}`" class="_link">@{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</MkA></div>
+		</template>
+		<template v-else-if="log.type === 'silenceUser'">
+			<div>{{ i18n.ts.user }}: <MkA :to="`/admin/user/${log.info.userId}`" class="_link">@{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</MkA></div>
+		</template>
+		<template v-else-if="log.type === 'unSilenceUser'">
+			<div>{{ i18n.ts.user }}: <MkA :to="`/admin/user/${log.info.userId}`" class="_link">@{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</MkA></div>
+		</template>
+		<template v-else-if="log.type === 'createAccount'">
+			<div>{{ i18n.ts.user }}: <MkA :to="`/admin/user/${log.info.userId}`" class="_link">@{{ log.info.userUsername }}</MkA></div>
+		</template>
+		<template v-else-if="log.type === 'clearOwnerlessFiles'">
+			<div>{{ i18n.ts.filesRemoved }}: {{ log.info.count }}</div>
+		</template>
+		<template v-else-if="log.type === 'clearInstanceFiles'">
+			<div>{{ i18n.ts.host }}: <MkA :to="`/instance-info/${log.info.host}`" class="_link">{{ log.info.host }}</MkA></div>
+			<div>{{ i18n.ts.filesRemoved }}: {{ log.info.count }}</div>
+		</template>
+		<template v-else-if="log.type === 'severFollowRelations'">
+			<div>{{ i18n.ts.host }}: <MkA :to="`/instance-info/${log.info.host}`" class="_link">{{ log.info.host }}</MkA></div>
+		</template>
 
 		<details>
 			<summary>raw</summary>
-- 
cgit v1.2.3-freya


From e5b8fc3c800abaca820f292e4481f7a338cde0f4 Mon Sep 17 00:00:00 2001
From: Hazelnoot <acomputerdog@gmail.com>
Date: Thu, 27 Feb 2025 10:29:03 -0500
Subject: add missing modlog render blocks

---
 locales/index.d.ts                                  |  6 +++++-
 packages/frontend/src/pages/admin/modlog.ModLog.vue | 15 +++++++++++++++
 sharkey-locales/en-US.yml                           |  3 ++-
 3 files changed, 22 insertions(+), 2 deletions(-)

(limited to 'packages/frontend/src/pages/admin/modlog.ModLog.vue')

diff --git a/locales/index.d.ts b/locales/index.d.ts
index ee99a9513d..25662afe6a 100644
--- a/locales/index.d.ts
+++ b/locales/index.d.ts
@@ -11662,9 +11662,13 @@ export interface Locale extends ILocale {
      */
     "flash": string;
     /**
-     * Files removed:
+     * Files removed
      */
     "filesRemoved": string;
+    /**
+     * File imported
+     */
+    "fileImported": string;
     /**
      * Failed to load no
      */
diff --git a/packages/frontend/src/pages/admin/modlog.ModLog.vue b/packages/frontend/src/pages/admin/modlog.ModLog.vue
index a4731af47b..1d60403f07 100644
--- a/packages/frontend/src/pages/admin/modlog.ModLog.vue
+++ b/packages/frontend/src/pages/admin/modlog.ModLog.vue
@@ -121,9 +121,11 @@ SPDX-License-Identifier: AGPL-3.0-only
 		<span v-else-if="log.type === 'silenceUser'">: @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</span>
 		<span v-else-if="log.type === 'unSilenceUser'">: @{{ log.info.userUsername }}{{ log.info.userHost ? '@' + log.info.userHost : '' }}</span>
 		<span v-else-if="log.type === 'createAccount'">: @{{ log.info.userUsername }}</span>
+		<span v-else-if="log.type === 'clearOwnerlessFiles'">: {{ log.info.count }}</span>
 		<span v-else-if="log.type === 'importCustomEmojis'">: {{ log.info.fileName }}</span>
 		<span v-else-if="log.type === 'clearInstanceFiles'">: {{ log.info.host }}</span>
 		<span v-else-if="log.type === 'severFollowRelations'">: {{ log.info.host }}</span>
+		<span v-else-if="log.type === 'createPromo'">: @{{ log.info.noteUserUsername }}{{ log.info.noteUserHost ? '@' + log.info.noteUserHost : '' }}</span>
 		<span v-else-if="log.type === 'addRelay'">: {{ log.info.inbox }}</span>
 		<span v-else-if="log.type === 'removeRelay'">: {{ log.info.inbox }}</span>
 	</template>
@@ -253,6 +255,9 @@ SPDX-License-Identifier: AGPL-3.0-only
 		<template v-else-if="log.type === 'clearOwnerlessFiles'">
 			<div>{{ i18n.ts.filesRemoved }}: {{ log.info.count }}</div>
 		</template>
+		<template v-else-if="log.type === 'importCustomEmojis'">
+			<div>{{ i18n.ts.fileImported }}: <MkA :to="`/admin/file/${log.info.fileId}`" class="_link">{{ log.info.fileName }}</MkA></div>
+		</template>
 		<template v-else-if="log.type === 'clearInstanceFiles'">
 			<div>{{ i18n.ts.host }}: <MkA :to="`/instance-info/${log.info.host}`" class="_link">{{ log.info.host }}</MkA></div>
 			<div>{{ i18n.ts.filesRemoved }}: {{ log.info.count }}</div>
@@ -260,6 +265,15 @@ SPDX-License-Identifier: AGPL-3.0-only
 		<template v-else-if="log.type === 'severFollowRelations'">
 			<div>{{ i18n.ts.host }}: <MkA :to="`/instance-info/${log.info.host}`" class="_link">{{ log.info.host }}</MkA></div>
 		</template>
+		<template v-else-if="log.type === 'createPromo'">
+			<SkFetchNote :noteId="log.info.noteId"/>
+		</template>
+		<template v-else-if="log.type === 'addRelay'">
+			<div>{{ i18n.ts.inboxUrl }}: {{ log.info.inbox }}</div>
+		</template>
+		<template v-else-if="log.type === 'removeRelay'">
+			<div>{{ i18n.ts.inboxUrl }}: {{ log.info.inbox }}</div>
+		</template>
 
 		<details>
 			<summary>raw</summary>
@@ -275,6 +289,7 @@ import { CodeDiff } from 'v-code-diff';
 import JSON5 from 'json5';
 import { i18n } from '@/i18n.js';
 import MkFolder from '@/components/MkFolder.vue';
+import SkFetchNote from '@/components/SkFetchNote.vue';
 
 const props = defineProps<{
 	log: Misskey.entities.ModerationLog;
diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml
index 5336a36340..f34f9a89c2 100644
--- a/sharkey-locales/en-US.yml
+++ b/sharkey-locales/en-US.yml
@@ -169,7 +169,8 @@ pinnedOnly: "Pinned"
 blockingYou: "Blocking you"
 warnExternalUrl: "Show warning when opening external URLs"
 flash: "Flash"
-filesRemoved: "Files removed:"
+filesRemoved: "Files removed"
+fileImported: "File imported"
 cannotLoadNote: "Failed to load no"
 _flash:
   contentHidden: "Flash Content Hidden"
-- 
cgit v1.2.3-freya


From 9fdb68d5689fc0f2ccbad0f02cd1f331e145ea6e Mon Sep 17 00:00:00 2001
From: Hazelnoot <acomputerdog@gmail.com>
Date: Sun, 2 Mar 2025 13:47:02 -0500
Subject: remove `fileId` from `importCustomEmojis` log

---
 packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts | 1 -
 packages/backend/src/types.ts                                       | 1 -
 packages/frontend/src/pages/admin/modlog.ModLog.vue                 | 2 +-
 packages/misskey-js/src/consts.ts                                   | 1 -
 4 files changed, 1 insertion(+), 4 deletions(-)

(limited to 'packages/frontend/src/pages/admin/modlog.ModLog.vue')

diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts
index b3dc3978d1..ee7706f31a 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts
@@ -35,7 +35,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 		super(meta, paramDef, async (ps, me) => {
 			const file = await driveFilesRepository.findOneByOrFail({ id: ps.fileId });
 			await this.moderationLogService.log(me, 'importCustomEmojis', {
-				fileId: file.id,
 				fileName: file.name,
 			});
 			await this.queueService.createImportCustomEmojisJob(me, ps.fileId);
diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts
index 6d58a9ef0a..2c6ef731b8 100644
--- a/packages/backend/src/types.ts
+++ b/packages/backend/src/types.ts
@@ -493,7 +493,6 @@ export type ModerationLogPayloads = {
 		delAliases?: string[],
 	},
 	importCustomEmojis: {
-		fileId: string,
 		fileName: string,
 	},
 	clearInstanceFiles: {
diff --git a/packages/frontend/src/pages/admin/modlog.ModLog.vue b/packages/frontend/src/pages/admin/modlog.ModLog.vue
index 1d60403f07..9ce6499e2d 100644
--- a/packages/frontend/src/pages/admin/modlog.ModLog.vue
+++ b/packages/frontend/src/pages/admin/modlog.ModLog.vue
@@ -256,7 +256,7 @@ SPDX-License-Identifier: AGPL-3.0-only
 			<div>{{ i18n.ts.filesRemoved }}: {{ log.info.count }}</div>
 		</template>
 		<template v-else-if="log.type === 'importCustomEmojis'">
-			<div>{{ i18n.ts.fileImported }}: <MkA :to="`/admin/file/${log.info.fileId}`" class="_link">{{ log.info.fileName }}</MkA></div>
+			<div>{{ i18n.ts.fileImported }}: {{ log.info.fileName }}</div>
 		</template>
 		<template v-else-if="log.type === 'clearInstanceFiles'">
 			<div>{{ i18n.ts.host }}: <MkA :to="`/instance-info/${log.info.host}`" class="_link">{{ log.info.host }}</MkA></div>
diff --git a/packages/misskey-js/src/consts.ts b/packages/misskey-js/src/consts.ts
index 137446e49f..0ce066182d 100644
--- a/packages/misskey-js/src/consts.ts
+++ b/packages/misskey-js/src/consts.ts
@@ -546,7 +546,6 @@ export type ModerationLogPayloads = {
 		delAliases?: string[],
 	};
 	importCustomEmojis: {
-		fileId: string,
 		fileName: string,
 	};
 	clearInstanceFiles: {
-- 
cgit v1.2.3-freya

