From 69b5b3c798c6eb8ba0644dae248841355608b633 Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Sun, 24 Dec 2023 17:06:06 +0900 Subject: [PATCH] fix: moderation log for makeNoteHome --- locales/ja-JP.yml | 1 + .../api/endpoints/admin/note-public-to-home.ts | 14 ++++++++++++-- packages/backend/src/types.ts | 6 +++++- .../frontend/src/pages/admin/modlog.ModLog.vue | 3 ++- packages/misskey-js/src/consts.ts | 8 ++++++++ packages/misskey-js/src/entities.ts | 3 +++ 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index d8055efdd66b..3793b91c7bd4 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2371,6 +2371,7 @@ _moderationLogTypes: deleteAvatarDecoration: "アイコンデコレーションを削除" unsetUserAvatar: "ユーザーのアイコンを解除" unsetUserBanner: "ユーザーのバナーを解除" + makeNoteHome: "ノートをホーム投稿に変更" _fileViewer: title: "ファイルの詳細" diff --git a/packages/backend/src/server/api/endpoints/admin/note-public-to-home.ts b/packages/backend/src/server/api/endpoints/admin/note-public-to-home.ts index 16186560b427..ad7c6af720c2 100644 --- a/packages/backend/src/server/api/endpoints/admin/note-public-to-home.ts +++ b/packages/backend/src/server/api/endpoints/admin/note-public-to-home.ts @@ -6,7 +6,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { DataSource } from 'typeorm'; import * as Redis from 'ioredis'; -import type { NotesRepository } from '@/models/_.js'; +import type { NotesRepository, UsersRepository } from '@/models/_.js'; import { MiNote, MiPoll } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { DI } from '@/di-symbols.js'; @@ -47,6 +47,9 @@ export const paramDef = { @Injectable() export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( + @Inject(DI.usersRepository) + private usersRepository: UsersRepository, + @Inject(DI.notesRepository) private notesRepository: NotesRepository, @@ -74,7 +77,14 @@ export default class extends Endpoint { // eslint- // Note: by design, visibility of replies and quoted renotes are not changed // replies and quoted renotes have their own text, so it's another moderation entity - await moderationLogService.log(me, 'makeNoteHome', { targetNoteId: note.id }); + const user = await this.usersRepository.findOneByOrFail({ id: note.userId }); + await moderationLogService.log(me, 'makeNoteHome', { + noteId: note.id, + noteUserId: note.userId, + noteUserUsername: user.username, + noteUserHost: user.host, + note: note, + }); // update basic note info await this.db.transaction(async transactionalEntityManager => { diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts index 42765eb174ca..8c08e592c097 100644 --- a/packages/backend/src/types.ts +++ b/packages/backend/src/types.ts @@ -269,7 +269,11 @@ export type ModerationLogPayloads = { fileId: string; }; makeNoteHome: { - targetNoteId: string; + noteId: string; + noteUserId: string; + noteUserUsername: string; + noteUserHost: string | null; + note: any; }; }; diff --git a/packages/frontend/src/pages/admin/modlog.ModLog.vue b/packages/frontend/src/pages/admin/modlog.ModLog.vue index 699b3c425ace..7800c37bb4b7 100644 --- a/packages/frontend/src/pages/admin/modlog.ModLog.vue +++ b/packages/frontend/src/pages/admin/modlog.ModLog.vue @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts._moderationLogTypes[log.type] }} @@ -40,6 +40,7 @@ SPDX-License-Identifier: AGPL-3.0-only : {{ log.info.avatarDecoration.name }} : {{ log.info.before.name }} : {{ log.info.avatarDecoration.name }} + : @{{ log.info.noteUserUsername }}{{ log.info.noteUserHost ? '@' + log.info.noteUserHost : '' }}