AbuseUserReport の category を camelCase にする & notLike で通報されないようにする (MisskeyIO#298)

This commit is contained in:
riku6460 2023-12-28 17:48:16 +09:00 committed by GitHub
parent 6de9a8ccbf
commit 2e2970eafd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 121 additions and 45 deletions

14
locales/index.d.ts vendored
View File

@ -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": {

View File

@ -1201,13 +1201,13 @@ _abuseReportCategory:
spam: "スパム"
explicit: "暴力もしくは攻撃的な投稿"
phishing: "フィッシングもしくは詐欺行為"
personalinfoleak: "本人もしくは他人の個人情報の漏えい"
selfharm: "自殺もしくは自害など生命に関わる問題"
criticalbreach: "重大な規約違反"
otherbreach: "その他の規約違反"
violationrights: "権利侵害もしくはなりすまし(本人)"
violationrightsother: "権利侵害(他人)"
notlike: "この人が気に入らない"
personalInfoLeak: "本人もしくは他人の個人情報の漏えい"
selfHarm: "自殺もしくは自害など生命に関わる問題"
criticalBreach: "重大な規約違反"
otherBreach: "その他の規約違反"
violationRights: "権利侵害もしくはなりすまし(本人)"
violationRightsOther: "権利侵害(他人)"
notLike: "この人が気に入らない"
other: "その他"
_announcement:

View File

@ -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'`);
}
}

View File

@ -77,7 +77,7 @@ export const meta = {
category: {
type: 'string',
nullable: false, optional: false,
}
},
},
},
},

View File

@ -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<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.cannotReportAdmin);
}
// for compatibility
if (ps.category === 'notlike') {
return;
}
const categoriesMap: Record<string, typeof paramDef['properties']['category']['enum'][number]> = {
'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<typeof meta, typeof paramDef> { // 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);

View File

@ -23,13 +23,13 @@ SPDX-License-Identifier: AGPL-3.0-only
<option value="spam">{{ i18n.ts._abuseReportCategory.spam }}</option>
<option value="explicit">{{ i18n.ts._abuseReportCategory.explicit }}</option>
<option value="phishing">{{ i18n.ts._abuseReportCategory.phishing }}</option>
<option value="personalinfoleak">{{ i18n.ts._abuseReportCategory.personalinfoleak }}</option>
<option value="selfharm">{{ i18n.ts._abuseReportCategory.selfharm }}</option>
<option value="criticalbreach">{{ i18n.ts._abuseReportCategory.criticalbreach }}</option>
<option value="otherbreach">{{ i18n.ts._abuseReportCategory.otherbreach }}</option>
<option value="violationrights">{{ i18n.ts._abuseReportCategory.violationrights }}</option>
<option value="violationrightsother">{{ i18n.ts._abuseReportCategory.violationrightsother }}</option>
<option value="notlike">{{ i18n.ts._abuseReportCategory.notlike }}</option>
<option value="personalInfoLeak">{{ i18n.ts._abuseReportCategory.personalInfoLeak }}</option>
<option value="selfHarm">{{ i18n.ts._abuseReportCategory.selfHarm }}</option>
<option value="criticalBreach">{{ i18n.ts._abuseReportCategory.criticalBreach }}</option>
<option value="otherBreach">{{ i18n.ts._abuseReportCategory.otherBreach }}</option>
<option value="violationRights">{{ i18n.ts._abuseReportCategory.violationRights }}</option>
<option value="violationRightsOther">{{ i18n.ts._abuseReportCategory.violationRightsOther }}</option>
<option value="notLike">{{ i18n.ts._abuseReportCategory.notLike }}</option>
<option value="other">{{ i18n.ts._abuseReportCategory.other }}</option>
</MkSelect>
</div>
@ -113,18 +113,19 @@ function refreshUserInfo() {
}
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,

View File

@ -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';

View File

@ -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 {

View File

@ -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';

View File

@ -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';

View File

@ -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';
};
};
};