From 055464a6241e10c8516ebee4ac9a01a2f753f8fb Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 28 Sep 2023 10:02:05 +0900 Subject: [PATCH] enhance: improve moderation log --- locales/index.d.ts | 1 + locales/ja-JP.yml | 1 + .../src/server/api/endpoints/admin/invite/create.ts | 7 +++++++ packages/backend/src/types.ts | 4 ++++ packages/misskey-js/etc/misskey-js.api.md | 5 ++++- packages/misskey-js/src/consts.ts | 4 ++++ packages/misskey-js/src/entities.ts | 3 +++ 7 files changed, 24 insertions(+), 1 deletion(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index 4d8123eb5d..5473a26fca 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -2277,6 +2277,7 @@ export interface Locale { "markSensitiveDriveFile": string; "unmarkSensitiveDriveFile": string; "resolveAbuseReport": string; + "createInvitation": string; }; } declare const locales: { diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 647f5fb5f0..ffe1d20e10 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2190,3 +2190,4 @@ _moderationLogTypes: markSensitiveDriveFile: "ファイルをセンシティブ付与" unmarkSensitiveDriveFile: "ファイルをセンシティブ解除" resolveAbuseReport: "通報を解決" + createInvitation: "招待コードを作成" diff --git a/packages/backend/src/server/api/endpoints/admin/invite/create.ts b/packages/backend/src/server/api/endpoints/admin/invite/create.ts index 7112e06bdc..2cc5ab6e35 100644 --- a/packages/backend/src/server/api/endpoints/admin/invite/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/invite/create.ts @@ -10,6 +10,7 @@ import { InviteCodeEntityService } from '@/core/entities/InviteCodeEntityService import { IdService } from '@/core/IdService.js'; import { DI } from '@/di-symbols.js'; import { generateInviteCode } from '@/misc/generate-invite-code.js'; +import { ModerationLogService } from '@/core/ModerationLogService.js'; import { ApiError } from '../../../error.js'; export const meta = { @@ -60,6 +61,7 @@ export default class extends Endpoint { // eslint- private inviteCodeEntityService: InviteCodeEntityService, private idService: IdService, + private moderationLogService: ModerationLogService, ) { super(meta, paramDef, async (ps, me) => { if (ps.expiresAt && isNaN(Date.parse(ps.expiresAt))) { @@ -78,6 +80,11 @@ export default class extends Endpoint { // eslint- } const tickets = await Promise.all(ticketsPromises); + + this.moderationLogService.log(me, 'createInvitation', { + invitations: tickets, + }); + return await this.inviteCodeEntityService.packMany(tickets, me); }); } diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts index 35ea710f9e..7b928263ab 100644 --- a/packages/backend/src/types.ts +++ b/packages/backend/src/types.ts @@ -56,6 +56,7 @@ export const moderationLogTypes = [ 'markSensitiveDriveFile', 'unmarkSensitiveDriveFile', 'resolveAbuseReport', + 'createInvitation', ] as const; export type ModerationLogPayloads = { @@ -198,4 +199,7 @@ export type ModerationLogPayloads = { report: any; forwarded: boolean; }; + createInvitation: { + invitations: any[]; + }; }; diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 0686354ff4..7d4d4cc8b8 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -2604,10 +2604,13 @@ type ModerationLog = { } | { type: 'unmarkSensitiveDriveFile'; info: ModerationLogPayloads['unmarkSensitiveDriveFile']; +} | { + type: 'createInvitation'; + info: ModerationLogPayloads['createInvitation']; }); // @public (undocumented) -export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "unsuspend", "updateUserNote", "addCustomEmoji", "updateCustomEmoji", "deleteCustomEmoji", "assignRole", "unassignRole", "createRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "updateGlobalAnnouncement", "updateUserAnnouncement", "deleteGlobalAnnouncement", "deleteUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance", "markSensitiveDriveFile", "unmarkSensitiveDriveFile", "resolveAbuseReport"]; +export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "unsuspend", "updateUserNote", "addCustomEmoji", "updateCustomEmoji", "deleteCustomEmoji", "assignRole", "unassignRole", "createRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue", "deleteDriveFile", "deleteNote", "createGlobalAnnouncement", "createUserAnnouncement", "updateGlobalAnnouncement", "updateUserAnnouncement", "deleteGlobalAnnouncement", "deleteUserAnnouncement", "resetPassword", "suspendRemoteInstance", "unsuspendRemoteInstance", "markSensitiveDriveFile", "unmarkSensitiveDriveFile", "resolveAbuseReport", "createInvitation"]; // @public (undocumented) export const mutedNoteReasons: readonly ["word", "manual", "spam", "other"]; diff --git a/packages/misskey-js/src/consts.ts b/packages/misskey-js/src/consts.ts index aedfb5570e..14a5b5643c 100644 --- a/packages/misskey-js/src/consts.ts +++ b/packages/misskey-js/src/consts.ts @@ -74,6 +74,7 @@ export const moderationLogTypes = [ 'markSensitiveDriveFile', 'unmarkSensitiveDriveFile', 'resolveAbuseReport', + 'createInvitation', ] as const; export type ModerationLogPayloads = { @@ -216,4 +217,7 @@ export type ModerationLogPayloads = { report: any; forwarded: boolean; }; + createInvitation: { + invitations: any[]; + }; }; diff --git a/packages/misskey-js/src/entities.ts b/packages/misskey-js/src/entities.ts index 41c9bdef6e..a089ef5a68 100644 --- a/packages/misskey-js/src/entities.ts +++ b/packages/misskey-js/src/entities.ts @@ -655,4 +655,7 @@ export type ModerationLog = { } | { type: 'unmarkSensitiveDriveFile'; info: ModerationLogPayloads['unmarkSensitiveDriveFile']; +} | { + type: 'createInvitation'; + info: ModerationLogPayloads['createInvitation']; });