From 1478a6c4ba91e7a2466cb2c7ec5c862f58f4178a Mon Sep 17 00:00:00 2001 From: CyberRex Date: Thu, 28 Dec 2023 12:16:34 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=9A=E5=A0=B1=E3=81=AE=E3=82=AB?= =?UTF-8?q?=E3=83=86=E3=82=B4=E3=83=AA=E3=83=BC=E5=8C=96=20(MisskeyIO#288)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/index.d.ts | 22 +++++ locales/ja-JP.yml | 22 +++++ ...703250468098-abuse-user-report-category.js | 18 ++++ .../entities/AbuseUserReportEntityService.ts | 1 + .../backend/src/models/AbuseUserReport.ts | 7 ++ .../models/json-schema/abuse-user-report.ts | 4 + .../api/endpoints/admin/abuse-user-reports.ts | 9 ++ .../api/endpoints/users/report-abuse.ts | 2 + .../frontend/src/components/MkAbuseReport.vue | 1 + .../src/components/MkAbuseReportWindow.vue | 94 +++++++++++++++++-- 10 files changed, 171 insertions(+), 9 deletions(-) create mode 100644 packages/backend/migration/1703250468098-abuse-user-report-category.js diff --git a/locales/index.d.ts b/locales/index.d.ts index f093bb3f33..d5e6d71b2b 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1190,6 +1190,28 @@ export interface Locale { "decorate": string; "addMfmFunction": string; "enableQuickAddMfmFunction": string; + "abuseReportCategory": string; + "selectCategory": string; + "reportComplete": string; + "blockThisUser": string; + "muteThisUser": string; + "_abuseReportMsgs": { + "rightsAbuseCantAccept": string; + }; + "_abuseReportCategory": { + "nsfw": string; + "spam": string; + "explicit": string; + "phishing": string; + "personalinfoleak": string; + "selfharm": string; + "criticalbreach": string; + "otherbreach": string; + "violationrights": string; + "violationrightsother": string; + "notlike": string; + "other": string; + }; "_announcement": { "forExistingUsers": string; "forExistingUsersDescription": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index d1952eec86..6382e64ad7 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1187,6 +1187,28 @@ seasonalScreenEffect: "季節に応じた画面の演出" decorate: "デコる" addMfmFunction: "装飾を追加" enableQuickAddMfmFunction: "高度なMFMのピッカーを表示する" +abuseReportCategory: "通報の種類" +selectCategory: "カテゴリを選択" +reportComplete: "通報完了" +blockThisUser: "このユーザーをブロックする" +muteThisUser: "このユーザーをミュートする" + +_abuseReportMsgs: + rightsAbuseCantAccept: "申し訳ございません。権利侵害の通報は権利者ご本人からのみ受け付けております。" + +_abuseReportCategory: + nsfw: "センシティブなコンテンツを含む投稿" + spam: "スパム" + explicit: "暴力もしくは攻撃的な投稿" + phishing: "フィッシングもしくは詐欺行為" + personalinfoleak: "本人もしくは他人の個人情報の漏えい" + selfharm: "自殺もしくは自害など生命に関わる問題" + criticalbreach: "重大な規約違反" + otherbreach: "その他の規約違反" + violationrights: "権利侵害もしくはなりすまし(本人)" + violationrightsother: "権利侵害(他人)" + notlike: "この人が気に入らない" + other: "その他" _announcement: forExistingUsers: "既存ユーザーのみ" diff --git a/packages/backend/migration/1703250468098-abuse-user-report-category.js b/packages/backend/migration/1703250468098-abuse-user-report-category.js new file mode 100644 index 0000000000..0fcce5c200 --- /dev/null +++ b/packages/backend/migration/1703250468098-abuse-user-report-category.js @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class AbuseUserReportCategory1703250468098 { + name = 'AbuseUserReportCategory1703250468098' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "abuse_user_report" ADD "category" character varying(20) NOT NULL DEFAULT 'other'`); + await queryRunner.query(`CREATE INDEX "IDX_5b9acc09094daeb8683e362778" ON "abuse_user_report" ("category") `); + } + + async down(queryRunner) { + await queryRunner.query(`DROP INDEX "public"."IDX_5b9acc09094daeb8683e362778"`); + await queryRunner.query(`ALTER TABLE "abuse_user_report" DROP COLUMN "category"`); + } +} diff --git a/packages/backend/src/core/entities/AbuseUserReportEntityService.ts b/packages/backend/src/core/entities/AbuseUserReportEntityService.ts index 2d6cb1b077..fe5e8e090b 100644 --- a/packages/backend/src/core/entities/AbuseUserReportEntityService.ts +++ b/packages/backend/src/core/entities/AbuseUserReportEntityService.ts @@ -50,6 +50,7 @@ export class AbuseUserReportEntityService { detail: true, }) : null, forwarded: report.forwarded, + category: report.category, }); } diff --git a/packages/backend/src/models/AbuseUserReport.ts b/packages/backend/src/models/AbuseUserReport.ts index 17491595c9..bd4f577882 100644 --- a/packages/backend/src/models/AbuseUserReport.ts +++ b/packages/backend/src/models/AbuseUserReport.ts @@ -67,6 +67,13 @@ export class MiAbuseUserReport { }) public comment: string; + @Index() + @Column('varchar', { + length: 20, nullable: false, + default: 'other', + }) + public category: string; + //#region Denormalized fields @Index() @Column('varchar', { diff --git a/packages/backend/src/models/json-schema/abuse-user-report.ts b/packages/backend/src/models/json-schema/abuse-user-report.ts index 648742ec98..89c25f066b 100644 --- a/packages/backend/src/models/json-schema/abuse-user-report.ts +++ b/packages/backend/src/models/json-schema/abuse-user-report.ts @@ -12,6 +12,10 @@ export const packedAbuseUserReportSchema = { format: 'id', example: 'xxxxxxxxxx', }, + category: { + type: 'string', + optional: false, nullable: false, + }, createdAt: { type: 'string', optional: false, nullable: false, diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts index 182b7feb36..9107d8d5e6 100644 --- a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts +++ b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts @@ -74,6 +74,10 @@ export const meta = { nullable: true, optional: true, ref: 'User', }, + category: { + type: 'string', + nullable: false, optional: false, + } }, }, }, @@ -89,6 +93,7 @@ export const paramDef = { reporterOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' }, targetUserOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' }, forwarded: { type: 'boolean', default: false }, + category: { type: 'string', nullable: true, default: null }, }, required: [], } as const; @@ -120,6 +125,10 @@ export default class extends Endpoint { // eslint- case 'remote': query.andWhere('report.targetUserHost IS NOT NULL'); break; } + if (ps.category) { + query.andWhere('report.category = :category', { category: ps.category }); + } + const reports = await query.limit(ps.limit).getMany(); return await this.abuseUserReportEntityService.packMany(reports, me); diff --git a/packages/backend/src/server/api/endpoints/users/report-abuse.ts b/packages/backend/src/server/api/endpoints/users/report-abuse.ts index 60d73f10ce..32728ac974 100644 --- a/packages/backend/src/server/api/endpoints/users/report-abuse.ts +++ b/packages/backend/src/server/api/endpoints/users/report-abuse.ts @@ -48,6 +48,7 @@ export const paramDef = { properties: { userId: { type: 'string', format: 'misskey:id' }, comment: { type: 'string', minLength: 1, maxLength: 2048 }, + category: { type: 'string', minLength: 1, maxLength: 20, default: 'other' }, }, required: ['userId', 'comment'], } as const; @@ -85,6 +86,7 @@ export default class extends Endpoint { // eslint- reporterId: me.id, reporterHost: null, comment: ps.comment, + category: ps.category, }).then(x => this.abuseUserReportsRepository.findOneByOrFail(x.identifiers[0])); this.queueService.createReportAbuseJob(report); diff --git a/packages/frontend/src/components/MkAbuseReport.vue b/packages/frontend/src/components/MkAbuseReport.vue index ce7e134b70..49cf5c1be4 100644 --- a/packages/frontend/src/components/MkAbuseReport.vue +++ b/packages/frontend/src/components/MkAbuseReport.vue @@ -28,6 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.moderator }}: +
カテゴリ: {{ i18n.t(`_abuseReportCategory.${report.category}`) }}
diff --git a/packages/frontend/src/components/MkAbuseReportWindow.vue b/packages/frontend/src/components/MkAbuseReportWindow.vue index 7814681ea2..4562e44573 100644 --- a/packages/frontend/src/components/MkAbuseReportWindow.vue +++ b/packages/frontend/src/components/MkAbuseReportWindow.vue @@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only -->