2023-07-27 14:31:52 +09:00
|
|
|
/*
|
2024-02-13 15:59:27 +00:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 14:31:52 +09:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2022-09-18 03:27:08 +09:00
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
|
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
2024-06-08 15:34:19 +09:00
|
|
|
import type { AbuseUserReportsRepository } from '@/models/_.js';
|
2022-09-18 03:27:08 +09:00
|
|
|
import { DI } from '@/di-symbols.js';
|
2024-06-08 15:34:19 +09:00
|
|
|
import { ApiError } from '@/server/api/error.js';
|
|
|
|
|
import { AbuseReportService } from '@/core/AbuseReportService.js';
|
2019-01-19 19:16:48 +09:00
|
|
|
|
|
|
|
|
export const meta = {
|
2019-02-23 11:20:58 +09:00
|
|
|
tags: ['admin'],
|
|
|
|
|
|
2022-01-18 22:27:10 +09:00
|
|
|
requireCredential: true,
|
2019-01-19 19:16:48 +09:00
|
|
|
requireModerator: true,
|
2023-12-27 15:08:59 +09:00
|
|
|
kind: 'write:admin:resolve-abuse-user-report',
|
2024-06-08 15:34:19 +09:00
|
|
|
|
|
|
|
|
errors: {
|
|
|
|
|
noSuchAbuseReport: {
|
|
|
|
|
message: 'No such abuse report.',
|
|
|
|
|
code: 'NO_SUCH_ABUSE_REPORT',
|
|
|
|
|
id: 'ac3794dd-2ce4-d878-e546-73c60c06b398',
|
|
|
|
|
kind: 'server',
|
|
|
|
|
httpStatusCode: 404,
|
|
|
|
|
},
|
|
|
|
|
},
|
2022-02-19 14:05:32 +09:00
|
|
|
} as const;
|
2019-01-19 19:16:48 +09:00
|
|
|
|
2022-02-20 13:15:40 +09:00
|
|
|
export const paramDef = {
|
2022-02-19 14:05:32 +09:00
|
|
|
type: 'object',
|
|
|
|
|
properties: {
|
|
|
|
|
reportId: { type: 'string', format: 'misskey:id' },
|
|
|
|
|
forward: { type: 'boolean', default: false },
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
2022-02-19 14:05:32 +09:00
|
|
|
required: ['reportId'],
|
2022-01-18 22:27:10 +09:00
|
|
|
} as const;
|
2019-01-19 19:16:48 +09:00
|
|
|
|
2022-09-18 03:27:08 +09:00
|
|
|
@Injectable()
|
2023-08-17 21:20:58 +09:00
|
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
2022-09-18 03:27:08 +09:00
|
|
|
constructor(
|
|
|
|
|
@Inject(DI.abuseUserReportsRepository)
|
|
|
|
|
private abuseUserReportsRepository: AbuseUserReportsRepository,
|
2024-06-08 15:34:19 +09:00
|
|
|
private abuseReportService: AbuseReportService,
|
2022-09-18 03:27:08 +09:00
|
|
|
) {
|
|
|
|
|
super(meta, paramDef, async (ps, me) => {
|
|
|
|
|
const report = await this.abuseUserReportsRepository.findOneBy({ id: ps.reportId });
|
2024-06-08 15:34:19 +09:00
|
|
|
if (!report) {
|
|
|
|
|
throw new ApiError(meta.errors.noSuchAbuseReport);
|
2022-09-18 03:27:08 +09:00
|
|
|
}
|
|
|
|
|
|
2024-06-08 15:34:19 +09:00
|
|
|
await this.abuseReportService.resolve([{ reportId: report.id, forward: ps.forward }], me);
|
2022-09-18 03:27:08 +09:00
|
|
|
});
|
2022-01-20 19:06:38 +01:00
|
|
|
}
|
2022-09-18 03:27:08 +09:00
|
|
|
}
|