diff --git a/locales/index.d.ts b/locales/index.d.ts index d5e6d71b2b..e4ddab3e01 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1203,13 +1203,13 @@ export interface Locale { "spam": string; "explicit": string; "phishing": string; - "personalinfoleak": string; - "selfharm": string; - "criticalbreach": string; - "otherbreach": string; - "violationrights": string; - "violationrightsother": string; - "notlike": string; + "personalInfoLeak": string; + "selfHarm": string; + "criticalBreach": string; + "otherBreach": string; + "violationRights": string; + "violationRightsOther": string; + "notLike": string; "other": string; }; "_announcement": { diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 6382e64ad7..a07ed32423 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1201,13 +1201,13 @@ _abuseReportCategory: spam: "スパム" explicit: "暴力もしくは攻撃的な投稿" phishing: "フィッシングもしくは詐欺行為" - personalinfoleak: "本人もしくは他人の個人情報の漏えい" - selfharm: "自殺もしくは自害など生命に関わる問題" - criticalbreach: "重大な規約違反" - otherbreach: "その他の規約違反" - violationrights: "権利侵害もしくはなりすまし(本人)" - violationrightsother: "権利侵害(他人)" - notlike: "この人が気に入らない" + personalInfoLeak: "本人もしくは他人の個人情報の漏えい" + selfHarm: "自殺もしくは自害など生命に関わる問題" + criticalBreach: "重大な規約違反" + otherBreach: "その他の規約違反" + violationRights: "権利侵害もしくはなりすまし(本人)" + violationRightsOther: "権利侵害(他人)" + notLike: "この人が気に入らない" other: "その他" _announcement: diff --git a/packages/backend/migration/1703749589203-abuse-user-report-category-camel-case.js b/packages/backend/migration/1703749589203-abuse-user-report-category-camel-case.js new file mode 100644 index 0000000000..6d653c0027 --- /dev/null +++ b/packages/backend/migration/1703749589203-abuse-user-report-category-camel-case.js @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class AbuseUserReportCategoryCamelCase1703749589203 { + name = 'AbuseUserReportCategoryCamelCase1703749589203' + + async up(queryRunner) { + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'personalInfoLeak' WHERE "category" = 'personalinfoleak'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'selfHarm' WHERE "category" = 'selfharm'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'criticalBreach' WHERE "category" = 'criticalbreach'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'otherBreach' WHERE "category" = 'otherbreach'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'violationRights' WHERE "category" = 'violationrights'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'violationRightsOther' WHERE "category" = 'violationrightsother'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'notLike' WHERE "category" = 'notlike'`); + } + + async down(queryRunner) { + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'personalinfoleak' WHERE "category" = 'personalInfoLeak'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'selfharm' WHERE "category" = 'selfHarm'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'criticalbreach' WHERE "category" = 'criticalBreach'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'otherbreach' WHERE "category" = 'otherBreach'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'violationrights' WHERE "category" = 'violationRights'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'violationrightsother' WHERE "category" = 'violationRightsOther'`); + await queryRunner.query(`UPDATE "abuse_user_report" SET "category" = 'notlike' WHERE "category" = 'notLike'`); + } +} 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 9107d8d5e6..aafd24843b 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 @@ -77,7 +77,7 @@ export const meta = { category: { type: 'string', nullable: false, optional: false, - } + }, }, }, }, 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 32728ac974..814a5fd623 100644 --- a/packages/backend/src/server/api/endpoints/users/report-abuse.ts +++ b/packages/backend/src/server/api/endpoints/users/report-abuse.ts @@ -48,7 +48,31 @@ 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' }, + category: { + type: 'string', + default: 'other', + enum: [ + 'nsfw', + 'spam', + 'explicit', + 'phishing', + 'personalInfoLeak', + 'selfHarm', + 'criticalBreach', + 'otherBreach', + 'violationRights', + 'violationRightsOther', + 'other', + // for compatibility + 'personalinfoleak', + 'selfharm', + 'criticalbreach', + 'otherbreach', + 'violationrights', + 'violationrightsother', + 'notlike', + ], + }, }, required: ['userId', 'comment'], } as const; @@ -79,6 +103,20 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.cannotReportAdmin); } + // for compatibility + if (ps.category === 'notlike') { + return; + } + + const categoriesMap: Record = { + 'personalinfoleak': 'personalInfoLeak', + 'selfharm': 'selfHarm', + 'criticalbreach': 'criticalBreach', + 'otherbreach': 'otherBreach', + 'violationrights': 'violationRights', + 'violationrightsother': 'violationRightsOther', + }; + const report = await this.abuseUserReportsRepository.insert({ id: this.idService.gen(), targetUserId: user.id, @@ -86,7 +124,7 @@ export default class extends Endpoint { // eslint- reporterId: me.id, reporterHost: null, comment: ps.comment, - category: ps.category, + category: typeof categoriesMap[ps.category] === 'string' ? categoriesMap[ps.category] : ps.category, }).then(x => this.abuseUserReportsRepository.findOneByOrFail(x.identifiers[0])); this.queueService.createReportAbuseJob(report); diff --git a/packages/frontend/src/components/MkAbuseReportWindow.vue b/packages/frontend/src/components/MkAbuseReportWindow.vue index 4562e44573..7423ea0c60 100644 --- a/packages/frontend/src/components/MkAbuseReportWindow.vue +++ b/packages/frontend/src/components/MkAbuseReportWindow.vue @@ -23,13 +23,13 @@ SPDX-License-Identifier: AGPL-3.0-only - - - - - - - + + + + + + + @@ -107,24 +107,25 @@ function muteUser() { function refreshUserInfo() { os.api('users/show', { userId: props.user.id }) - .then((res) => { - fullUserInfo.value = res; - }); + .then((res) => { + fullUserInfo.value = res; + }); } function send() { - if (category.value === 'violationrightsother') { + if (category.value === 'violationRightsOther') { os.alert({ type: 'info', - text: i18n.ts._abuseReportMsgs.rightsAbuseCantAccept + text: i18n.ts._abuseReportMsgs.rightsAbuseCantAccept, }); uiWindow.value?.close(); emit('closed'); return; } - if (category.value === 'notlike') { + if (category.value === 'notLike') { uiWindow.value?.close(); page.value = 2; + return; } os.apiWithDialog('users/report-abuse', { userId: props.user.id, @@ -132,11 +133,11 @@ function send() { category: category.value, }, undefined).then(res => { os.api('users/show', { userId: props.user.id }) - .then((res) => { - fullUserInfo.value = res; - uiWindow.value?.close(); - page.value = 2; - }); + .then((res) => { + fullUserInfo.value = res; + uiWindow.value?.close(); + page.value = 2; + }); }); } diff --git a/packages/misskey-js/src/autogen/apiClientJSDoc.ts b/packages/misskey-js/src/autogen/apiClientJSDoc.ts index 043c83194f..4481d7f791 100644 --- a/packages/misskey-js/src/autogen/apiClientJSDoc.ts +++ b/packages/misskey-js/src/autogen/apiClientJSDoc.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.1-io - * generatedAt: 2023-12-27T19:40:57.229Z + * version: 2023.12.2-io + * generatedAt: 2023-12-28T08:11:13.114Z */ import type { SwitchCaseResponseType } from '../api.js'; diff --git a/packages/misskey-js/src/autogen/endpoint.ts b/packages/misskey-js/src/autogen/endpoint.ts index 1778f01d0a..140249700d 100644 --- a/packages/misskey-js/src/autogen/endpoint.ts +++ b/packages/misskey-js/src/autogen/endpoint.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.1-io - * generatedAt: 2023-12-27T19:40:57.223Z + * version: 2023.12.2-io + * generatedAt: 2023-12-28T08:11:13.103Z */ import type { diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts index 91473c2051..1ba7eecc47 100644 --- a/packages/misskey-js/src/autogen/entities.ts +++ b/packages/misskey-js/src/autogen/entities.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.1-io - * generatedAt: 2023-12-27T19:40:57.217Z + * version: 2023.12.2-io + * generatedAt: 2023-12-28T08:11:13.098Z */ import { operations } from './types.js'; diff --git a/packages/misskey-js/src/autogen/models.ts b/packages/misskey-js/src/autogen/models.ts index e0996867d3..3f5c8b96d9 100644 --- a/packages/misskey-js/src/autogen/models.ts +++ b/packages/misskey-js/src/autogen/models.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.1-io - * generatedAt: 2023-12-27T19:40:57.214Z + * version: 2023.12.2-io + * generatedAt: 2023-12-28T08:11:13.095Z */ import { components } from './types.js'; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 26abaad8df..03b17ba975 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -2,8 +2,8 @@ /* eslint @typescript-eslint/no-explicit-any: 0 */ /* - * version: 2023.12.1-io - * generatedAt: 2023-12-27T19:40:56.996Z + * version: 2023.12.2-io + * generatedAt: 2023-12-28T08:11:12.906Z */ /** @@ -4478,6 +4478,7 @@ export type components = { * @example xxxxxxxxxx */ id: string; + category: string; /** Format: date-time */ createdAt: string; comment: string; @@ -4696,6 +4697,8 @@ export type operations = { targetUserOrigin?: 'combined' | 'local' | 'remote'; /** @default false */ forwarded?: boolean; + /** @default null */ + category?: string | null; }; }; }; @@ -4723,6 +4726,7 @@ export type operations = { reporter: components['schemas']['User']; targetUser: components['schemas']['User']; assignee?: components['schemas']['User'] | null; + category: string; })[]; }; }; @@ -25233,6 +25237,11 @@ export type operations = { /** Format: misskey:id */ userId: string; comment: string; + /** + * @default other + * @enum {string} + */ + category?: 'nsfw' | 'spam' | 'explicit' | 'phishing' | 'personalInfoLeak' | 'selfHarm' | 'criticalBreach' | 'otherBreach' | 'violationRights' | 'violationRightsOther' | 'other' | 'personalinfoleak' | 'selfharm' | 'criticalbreach' | 'otherbreach' | 'violationrights' | 'violationrightsother' | 'notlike'; }; }; };