feat: 完成举报拉黑和审核处置闭环
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Inject,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Post,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from "@nestjs/common";
|
||||
import { AuthGuard } from "../auth/auth.guard.js";
|
||||
import { CurrentUser } from "../auth/current-user.decorator.js";
|
||||
import type { AccessClaims } from "../auth/token.service.js";
|
||||
import { StateChangingOriginGuard } from "../conversation/state-changing-origin.guard.js";
|
||||
import { AdminGuard } from "./admin.guard.js";
|
||||
import { AdminService } from "./admin.service.js";
|
||||
import {
|
||||
AdminQueryDto,
|
||||
ModerateDto,
|
||||
ResolveReportDto,
|
||||
SanctionDto,
|
||||
} from "./dto.js";
|
||||
@Controller("admin")
|
||||
@UseGuards(AuthGuard, AdminGuard)
|
||||
export class AdminController {
|
||||
constructor(@Inject(AdminService) private readonly admin: AdminService) {}
|
||||
@Get("reports") reports(@Query() q: AdminQueryDto) {
|
||||
return this.admin.reports(q.status, q.limit);
|
||||
}
|
||||
@UseGuards(StateChangingOriginGuard) @Post("reports/:id/resolve") resolve(
|
||||
@CurrentUser() u: AccessClaims,
|
||||
@Param("id", new ParseUUIDPipe()) id: string,
|
||||
@Body() d: ResolveReportDto,
|
||||
) {
|
||||
return this.admin.resolve(u.sub, id, d);
|
||||
}
|
||||
@Get("moderation") moderation(@Query() q: AdminQueryDto) {
|
||||
return this.admin.moderation(q.limit);
|
||||
}
|
||||
@UseGuards(StateChangingOriginGuard) @Post("moderation/:id/resolve") moderate(
|
||||
@CurrentUser() u: AccessClaims,
|
||||
@Param("id", new ParseUUIDPipe()) id: string,
|
||||
@Body() d: ModerateDto,
|
||||
) {
|
||||
return this.admin.moderate(u.sub, id, d.decision, d.reason);
|
||||
}
|
||||
@UseGuards(StateChangingOriginGuard)
|
||||
@Post("accounts/:publicId/sanctions")
|
||||
sanction(
|
||||
@CurrentUser() u: AccessClaims,
|
||||
@Param("publicId", new ParseUUIDPipe()) id: string,
|
||||
@Body() d: SanctionDto,
|
||||
) {
|
||||
return this.admin.sanctions(u.sub, id, d);
|
||||
}
|
||||
}
|
||||
|
||||
Reflect.defineMetadata(
|
||||
"design:paramtypes",
|
||||
[AdminQueryDto],
|
||||
AdminController.prototype,
|
||||
"reports",
|
||||
);
|
||||
Reflect.defineMetadata(
|
||||
"design:paramtypes",
|
||||
[Object, String, ResolveReportDto],
|
||||
AdminController.prototype,
|
||||
"resolve",
|
||||
);
|
||||
Reflect.defineMetadata(
|
||||
"design:paramtypes",
|
||||
[AdminQueryDto],
|
||||
AdminController.prototype,
|
||||
"moderation",
|
||||
);
|
||||
Reflect.defineMetadata(
|
||||
"design:paramtypes",
|
||||
[Object, String, ModerateDto],
|
||||
AdminController.prototype,
|
||||
"moderate",
|
||||
);
|
||||
Reflect.defineMetadata(
|
||||
"design:paramtypes",
|
||||
[Object, String, SanctionDto],
|
||||
AdminController.prototype,
|
||||
"sanction",
|
||||
);
|
||||
Reference in New Issue
Block a user