This commit is contained in:
syuilo 2023-09-23 17:47:21 +09:00
parent f24e388458
commit a87b99b41b
13 changed files with 74 additions and 56 deletions

8
locales/index.d.ts vendored
View File

@ -2249,6 +2249,14 @@ export interface Locale {
"mention": string; "mention": string;
}; };
}; };
"_moderationLogTypes": {
"roleAssigned": string;
"roleUnassigned": string;
"roleUpdated": string;
"suspend": string;
"unsuspend": string;
"addEmoji": string;
};
} }
declare const locales: { declare const locales: {
[lang: string]: Locale; [lang: string]: Locale;

View File

@ -2161,3 +2161,13 @@ _webhookSettings:
renote: "Renoteされたとき" renote: "Renoteされたとき"
reaction: "リアクションがあったとき" reaction: "リアクションがあったとき"
mention: "メンションされたとき" mention: "メンションされたとき"
_moderationLogTypes:
assignRole: "ロールへアサイン"
unassignRole: "ロールのアサイン解除"
updateRole: "ロール設定更新"
suspend: "凍結"
unsuspend: "凍結解除"
addCustomEmoji: "カスタム絵文字追加"
updateServerSettings: "サーバー設定更新"
updateUserNote: "モデレーションノート更新"

View File

@ -412,7 +412,7 @@ export class RoleService implements OnApplicationShutdown {
this.globalEventService.publishInternalEvent('userRoleAssigned', created); this.globalEventService.publishInternalEvent('userRoleAssigned', created);
if (moderator) { if (moderator) {
this.moderationLogService.log(moderator, 'roleAssigned', { this.moderationLogService.log(moderator, 'assignRole', {
roleId: roleId, roleId: roleId,
roleName: role.name, roleName: role.name,
userId: userId, userId: userId,
@ -446,7 +446,7 @@ export class RoleService implements OnApplicationShutdown {
if (moderator) { if (moderator) {
const role = await this.rolesRepository.findOneByOrFail({ id: roleId }); const role = await this.rolesRepository.findOneByOrFail({ id: roleId });
this.moderationLogService.log(moderator, 'roleUnassigned', { this.moderationLogService.log(moderator, 'unassignRole', {
roleId: roleId, roleId: roleId,
roleName: role.name, roleName: role.name,
userId: userId, userId: userId,
@ -485,7 +485,7 @@ export class RoleService implements OnApplicationShutdown {
this.globalEventService.publishInternalEvent('roleUpdated', updated); this.globalEventService.publishInternalEvent('roleUpdated', updated);
if (moderator) { if (moderator) {
this.moderationLogService.log(moderator, 'roleUpdated', { this.moderationLogService.log(moderator, 'updateRole', {
roleId: role.id, roleId: role.id,
before: role, before: role,
after: updated, after: updated,

View File

@ -79,7 +79,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [], roleIdsThatCanBeUsedThisEmojiAsReaction: ps.roleIdsThatCanBeUsedThisEmojiAsReaction ?? [],
}); });
this.moderationLogService.log(me, 'addEmoji', { this.moderationLogService.log(me, 'addCustomEmoji', {
emojiId: emoji.id, emojiId: emoji.id,
}); });

View File

@ -83,7 +83,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
return; return;
} }
await this.roleService.assign(user.id, role.id, ps.expiresAt ? new Date(ps.expiresAt) : null); await this.roleService.assign(user.id, role.id, ps.expiresAt ? new Date(ps.expiresAt) : null, me);
}); });
} }
} }

View File

@ -81,7 +81,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.noSuchUser); throw new ApiError(meta.errors.noSuchUser);
} }
await this.roleService.unassign(user.id, role.id); await this.roleService.unassign(user.id, role.id, me);
}); });
} }
} }

View File

@ -447,7 +447,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const after = await this.metaService.fetch(true); const after = await this.metaService.fetch(true);
this.moderationLogService.log(me, 'updateMeta', { this.moderationLogService.log(me, 'updateServerSettings', {
before, before,
after, after,
}); });

View File

@ -49,7 +49,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
moderationNote: ps.text, moderationNote: ps.text,
}); });
this.moderationLogService.log(me, 'userNoteUpdated', { this.moderationLogService.log(me, 'updateServerSettings', {
userId: user.id, userId: user.id,
before: currentProfile.moderationNote, before: currentProfile.moderationNote,
after: ps.text, after: ps.text,

View File

@ -27,10 +27,10 @@ export const mutedNoteReasons = ['word', 'manual', 'spam', 'other'] as const;
export const ffVisibility = ['public', 'followers', 'private'] as const; export const ffVisibility = ['public', 'followers', 'private'] as const;
export const moderationLogTypes = ['updateMeta', 'suspend', 'unsuspend', 'userNoteUpdated', 'addEmoji', 'roleAssigned', 'roleUnassigned', 'roleUpdated', 'roleDeleted', 'clearQueue', 'promoteQueue'] as const; export const moderationLogTypes = ['updateServerSettings', 'suspend', 'unsuspend', 'updateUserNote', 'addCustomEmoji', 'assignRole', 'unassignRole', 'updateRole', 'deleteRole', 'clearQueue', 'promoteQueue'] as const;
export type ModerationLogPayloads = { export type ModerationLogPayloads = {
updateMeta: { updateServerSettings: {
before: any | null; before: any | null;
after: any | null; after: any | null;
}; };
@ -40,31 +40,31 @@ export type ModerationLogPayloads = {
unsuspend: { unsuspend: {
targetId: string; targetId: string;
}; };
userNoteUpdated: { updateUserNote: {
userId: string; userId: string;
before: string | null; before: string | null;
after: string | null; after: string | null;
}; };
addEmoji: { addCustomEmoji: {
emojiId: string; emojiId: string;
}; };
roleAssigned: { assignRole: {
userId: string; userId: string;
roleId: string; roleId: string;
roleName: string; roleName: string;
expiresAt: string | null; expiresAt: string | null;
}; };
roleUnassigned: { unassignRole: {
userId: string; userId: string;
roleId: string; roleId: string;
roleName: string; roleName: string;
}; };
roleUpdated: { updateRole: {
roleId: string; roleId: string;
before: any; before: any;
after: any; after: any;
}; };
roleDeleted: { deleteRole: {
roleId: string; roleId: string;
roleName: string; roleName: string;
}; };

View File

@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template> <template>
<MkFolder> <MkFolder>
<template #label>{{ log.type }}</template> <template #label>{{ i18n.ts._moderationLogTypes[log.type] }}</template>
<template #icon> <template #icon>
<MkAvatar :user="log.user" :class="$style.avatar"/> <MkAvatar :user="log.user" :class="$style.avatar"/>
</template> </template>
@ -22,11 +22,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<template v-else-if="log.type === 'unsuspend'"> <template v-else-if="log.type === 'unsuspend'">
<div>{{ i18n.ts.user }}: {{ log.info.targetId }}</div> <div>{{ i18n.ts.user }}: {{ log.info.targetId }}</div>
</template> </template>
<template v-else-if="log.type === 'roleAssigned'"> <template v-else-if="log.type === 'assignRole'">
<div>{{ i18n.ts.user }}: {{ log.info.userId }}</div> <div>{{ i18n.ts.user }}: {{ log.info.userId }}</div>
<div>{{ i18n.ts.role }}: {{ log.info.roleName }} [{{ log.info.roleId }}]</div> <div>{{ i18n.ts.role }}: {{ log.info.roleName }} [{{ log.info.roleId }}]</div>
</template> </template>
<template v-else-if="log.type === 'roleUnassigned'"> <template v-else-if="log.type === 'unassignRole'">
<div>{{ i18n.ts.user }}: {{ log.info.userId }}</div> <div>{{ i18n.ts.user }}: {{ log.info.userId }}</div>
<div>{{ i18n.ts.role }}: {{ log.info.roleName }} [{{ log.info.roleId }}]</div> <div>{{ i18n.ts.role }}: {{ log.info.roleName }} [{{ log.info.roleId }}]</div>
</template> </template>

View File

@ -2524,8 +2524,8 @@ type ModerationLog = {
userId: User['id']; userId: User['id'];
user: UserDetailed | null; user: UserDetailed | null;
} & ({ } & ({
type: 'updateMeta'; type: 'updateServerSettings';
info: ModerationLogPayloads['updateMeta']; info: ModerationLogPayloads['updateServerSettings'];
} | { } | {
type: 'suspend'; type: 'suspend';
info: ModerationLogPayloads['suspend']; info: ModerationLogPayloads['suspend'];
@ -2533,23 +2533,23 @@ type ModerationLog = {
type: 'unsuspend'; type: 'unsuspend';
info: ModerationLogPayloads['unsuspend']; info: ModerationLogPayloads['unsuspend'];
} | { } | {
type: 'userNoteUpdated'; type: 'updateUserNote';
info: ModerationLogPayloads['userNoteUpdated']; info: ModerationLogPayloads['updateUserNote'];
} | { } | {
type: 'addEmoji'; type: 'addCustomEmoji';
info: ModerationLogPayloads['addEmoji']; info: ModerationLogPayloads['addCustomEmoji'];
} | { } | {
type: 'roleAssigned'; type: 'assignRole';
info: ModerationLogPayloads['roleAssigned']; info: ModerationLogPayloads['assignRole'];
} | { } | {
type: 'roleUnassigned'; type: 'unassignRole';
info: ModerationLogPayloads['roleUnassigned']; info: ModerationLogPayloads['unassignRole'];
} | { } | {
type: 'roleUpdated'; type: 'updateRole';
info: ModerationLogPayloads['roleUpdated']; info: ModerationLogPayloads['updateRole'];
} | { } | {
type: 'roleDeleted'; type: 'deleteRole';
info: ModerationLogPayloads['roleDeleted']; info: ModerationLogPayloads['deleteRole'];
} | { } | {
type: 'clearQueue'; type: 'clearQueue';
info: ModerationLogPayloads['clearQueue']; info: ModerationLogPayloads['clearQueue'];
@ -2559,7 +2559,7 @@ type ModerationLog = {
}); });
// @public (undocumented) // @public (undocumented)
export const moderationLogTypes: readonly ["updateMeta", "suspend", "unsuspend", "userNoteUpdated", "addEmoji", "roleAssigned", "roleUnassigned", "roleUpdated", "roleDeleted", "clearQueue", "promoteQueue"]; export const moderationLogTypes: readonly ["updateServerSettings", "suspend", "unsuspend", "updateUserNote", "addCustomEmoji", "assignRole", "unassignRole", "updateRole", "deleteRole", "clearQueue", "promoteQueue"];
// @public (undocumented) // @public (undocumented)
export const mutedNoteReasons: readonly ["word", "manual", "spam", "other"]; export const mutedNoteReasons: readonly ["word", "manual", "spam", "other"];

View File

@ -45,10 +45,10 @@ export const permissions = [
'write:flash-likes', 'write:flash-likes',
]; ];
export const moderationLogTypes = ['updateMeta', 'suspend', 'unsuspend', 'userNoteUpdated', 'addEmoji', 'roleAssigned', 'roleUnassigned', 'roleUpdated', 'roleDeleted', 'clearQueue', 'promoteQueue'] as const; export const moderationLogTypes = ['updateServerSettings', 'suspend', 'unsuspend', 'updateUserNote', 'addCustomEmoji', 'assignRole', 'unassignRole', 'updateRole', 'deleteRole', 'clearQueue', 'promoteQueue'] as const;
export type ModerationLogPayloads = { export type ModerationLogPayloads = {
updateMeta: { updateServerSettings: {
before: any | null; before: any | null;
after: any | null; after: any | null;
}; };
@ -58,31 +58,31 @@ export type ModerationLogPayloads = {
unsuspend: { unsuspend: {
targetId: string; targetId: string;
}; };
userNoteUpdated: { updateUserNote: {
userId: string; userId: string;
before: string | null; before: string | null;
after: string | null; after: string | null;
}; };
addEmoji: { addCustomEmoji: {
emojiId: string; emojiId: string;
}; };
roleAssigned: { assignRole: {
userId: string; userId: string;
roleId: string; roleId: string;
roleName: string; roleName: string;
expiresAt: string | null; expiresAt: string | null;
}; };
roleUnassigned: { unassignRole: {
userId: string; userId: string;
roleId: string; roleId: string;
roleName: string; roleName: string;
}; };
roleUpdated: { updateRole: {
roleId: string; roleId: string;
before: any; before: any;
after: any; after: any;
}; };
roleDeleted: { deleteRole: {
roleId: string; roleId: string;
roleName: string; roleName: string;
}; };

View File

@ -575,8 +575,8 @@ export type ModerationLog = {
userId: User['id']; userId: User['id'];
user: UserDetailed | null; user: UserDetailed | null;
} & ({ } & ({
type: 'updateMeta'; type: 'updateServerSettings';
info: ModerationLogPayloads['updateMeta']; info: ModerationLogPayloads['updateServerSettings'];
} | { } | {
type: 'suspend'; type: 'suspend';
info: ModerationLogPayloads['suspend']; info: ModerationLogPayloads['suspend'];
@ -584,23 +584,23 @@ export type ModerationLog = {
type: 'unsuspend'; type: 'unsuspend';
info: ModerationLogPayloads['unsuspend']; info: ModerationLogPayloads['unsuspend'];
} | { } | {
type: 'userNoteUpdated'; type: 'updateUserNote';
info: ModerationLogPayloads['userNoteUpdated']; info: ModerationLogPayloads['updateUserNote'];
} | { } | {
type: 'addEmoji'; type: 'addCustomEmoji';
info: ModerationLogPayloads['addEmoji']; info: ModerationLogPayloads['addCustomEmoji'];
} | { } | {
type: 'roleAssigned'; type: 'assignRole';
info: ModerationLogPayloads['roleAssigned']; info: ModerationLogPayloads['assignRole'];
} | { } | {
type: 'roleUnassigned'; type: 'unassignRole';
info: ModerationLogPayloads['roleUnassigned']; info: ModerationLogPayloads['unassignRole'];
} | { } | {
type: 'roleUpdated'; type: 'updateRole';
info: ModerationLogPayloads['roleUpdated']; info: ModerationLogPayloads['updateRole'];
} | { } | {
type: 'roleDeleted'; type: 'deleteRole';
info: ModerationLogPayloads['roleDeleted']; info: ModerationLogPayloads['deleteRole'];
} | { } | {
type: 'clearQueue'; type: 'clearQueue';
info: ModerationLogPayloads['clearQueue']; info: ModerationLogPayloads['clearQueue'];