Skip to content

Commit

Permalink
Merge pull request #121 from Sayamame-beans/fix-118
Browse files Browse the repository at this point in the history
fix moderation log and add i18n for makeNoteHome
  • Loading branch information
Sayamame-beans authored Dec 24, 2023
2 parents 6a249bb + 1f1558a commit a1ba7dc
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 7 deletions.
3 changes: 3 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface Locale {
"delete": string;
"deleteAndEdit": string;
"deleteAndEditConfirm": string;
"makeNoteHome": string;
"addToList": string;
"addToAntenna": string;
"sendMessage": string;
Expand Down Expand Up @@ -232,6 +233,7 @@ export interface Locale {
"noUsers": string;
"editProfile": string;
"noteDeleteConfirm": string;
"makeNoteHomeConfirm": string;
"pinLimitExceeded": string;
"intro": string;
"done": string;
Expand Down Expand Up @@ -2470,6 +2472,7 @@ export interface Locale {
"deleteAvatarDecoration": string;
"unsetUserAvatar": string;
"unsetUserBanner": string;
"makeNoteHome": string;
};
"_fileViewer": {
"title": string;
Expand Down
3 changes: 3 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ copyLinkRenote: "リノートのリンクをコピー"
delete: "削除"
deleteAndEdit: "削除して編集"
deleteAndEditConfirm: "このノートを削除してもう一度編集しますか?このノートへのリアクション、リノート、返信も全て削除されます。"
makeNoteHome: "ホーム投稿にする"
addToList: "リストに追加"
addToAntenna: "アンテナに追加"
sendMessage: "メッセージを送信"
Expand Down Expand Up @@ -229,6 +230,7 @@ blockedUsers: "ブロックしたユーザー"
noUsers: "ユーザーはいません"
editProfile: "プロフィールを編集"
noteDeleteConfirm: "このノートを削除しますか?"
makeNoteHomeConfirm: "本当にホーム投稿にしますか?"
pinLimitExceeded: "これ以上ピン留めできません"
intro: "Misskeyのインストールが完了しました!管理者アカウントを作成しましょう。"
done: "完了"
Expand Down Expand Up @@ -2371,6 +2373,7 @@ _moderationLogTypes:
deleteAvatarDecoration: "アイコンデコレーションを削除"
unsetUserAvatar: "ユーザーのアイコンを解除"
unsetUserBanner: "ユーザーのバナーを解除"
makeNoteHome: "ノートをホーム投稿に変更"

_fileViewer:
title: "ファイルの詳細"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -47,6 +47,9 @@ export const paramDef = {
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
constructor(
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,

@Inject(DI.notesRepository)
private notesRepository: NotesRepository,

Expand Down Expand Up @@ -74,7 +77,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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 => {
Expand Down
6 changes: 5 additions & 1 deletion packages/backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ export type ModerationLogPayloads = {
fileId: string;
};
makeNoteHome: {
targetNoteId: string;
noteId: string;
noteUserId: string;
noteUserUsername: string;
noteUserHost: string | null;
note: any;
};
};

Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/pages/admin/modlog.ModLog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<b
:class="{
[$style.logGreen]: ['createRole', 'addCustomEmoji', 'createGlobalAnnouncement', 'createUserAnnouncement', 'createAd', 'createInvitation', 'createAvatarDecoration'].includes(log.type),
[$style.logYellow]: ['markSensitiveDriveFile', 'resetPassword'].includes(log.type),
[$style.logYellow]: ['markSensitiveDriveFile', 'resetPassword', 'makeNoteHome'].includes(log.type),
[$style.logRed]: ['suspend', 'deleteRole', 'suspendRemoteInstance', 'deleteGlobalAnnouncement', 'deleteUserAnnouncement', 'deleteCustomEmoji', 'deleteNote', 'deleteDriveFile', 'deleteAd', 'deleteAvatarDecoration'].includes(log.type)
}"
>{{ i18n.ts._moderationLogTypes[log.type] }}</b>
Expand Down Expand Up @@ -40,6 +40,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<span v-else-if="log.type === 'createAvatarDecoration'">: {{ log.info.avatarDecoration.name }}</span>
<span v-else-if="log.type === 'updateAvatarDecoration'">: {{ log.info.before.name }}</span>
<span v-else-if="log.type === 'deleteAvatarDecoration'">: {{ log.info.avatarDecoration.name }}</span>
<span v-else-if="log.type === 'makeNoteHome'">: @{{ log.info.noteUserUsername }}{{ log.info.noteUserHost ? '@' + log.info.noteUserHost : '' }}</span>
</template>
<template #icon>
<MkAvatar :user="log.user" :class="$style.avatar"/>
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function getNoteMenu(props: {
function makeHome(): void {
os.confirm({
type: 'warning',
text: '本当にホーム投稿にしますか?',
text: i18n.ts.makeNoteHomeConfirm,
}).then(({ canceled }) => {
if (canceled) return;

Expand Down Expand Up @@ -378,7 +378,7 @@ export function getNoteMenu(props: {
},
$i.isModerator || $i.isAdmin ? {
icon: 'ti ti-home',
text: 'ホーム投稿にする', // めんどうなのでとりあえずハードコード
text: i18n.ts.makeNoteHome,
danger: true,
action: makeHome,
} : undefined]
Expand Down
5 changes: 4 additions & 1 deletion packages/misskey-js/etc/misskey-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2260,10 +2260,13 @@ type ModerationLog = {
} | {
type: 'unsetUserBanner';
info: ModerationLogPayloads['unsetUserBanner'];
} | {
type: 'makeNoteHome';
info: ModerationLogPayloads['makeNoteHome'];
});

// @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", "createInvitation", "createAd", "updateAd", "deleteAd", "createAvatarDecoration", "updateAvatarDecoration", "deleteAvatarDecoration", "unsetUserAvatar", "unsetUserBanner"];
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", "createAd", "updateAd", "deleteAd", "createAvatarDecoration", "updateAvatarDecoration", "deleteAvatarDecoration", "unsetUserAvatar", "unsetUserBanner", "makeNoteHome"];

// @public (undocumented)
type MuteCreateRequest = operations['mute/create']['requestBody']['content']['application/json'];
Expand Down
8 changes: 8 additions & 0 deletions packages/misskey-js/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const moderationLogTypes = [
'deleteAvatarDecoration',
'unsetUserAvatar',
'unsetUserBanner',
'makeNoteHome',
] as const;

export type ModerationLogPayloads = {
Expand Down Expand Up @@ -271,4 +272,11 @@ export type ModerationLogPayloads = {
userHost: string | null;
fileId: string;
};
makeNoteHome: {
noteId: string;
noteUserId: string;
noteUserUsername: string;
noteUserHost: string | null;
note: any;
};
};
3 changes: 3 additions & 0 deletions packages/misskey-js/src/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ export type ModerationLog = {
} | {
type: 'unsetUserBanner';
info: ModerationLogPayloads['unsetUserBanner'];
} | {
type: 'makeNoteHome';
info: ModerationLogPayloads['makeNoteHome'];
});

export type ServerStats = {
Expand Down

0 comments on commit a1ba7dc

Please sign in to comment.