Deleted unused e2e tests, mocks (`cuid2`, `jose`, `ml-kem`, `sha3`), and their associated jest configurations. Simplified services by ensuring proper dependency imports, resolving circular references, and improving TypeScript type usage for enhanced maintainability and testability. Upgraded Dockerfile base image to match new development standards.
34 lines
1012 B
TypeScript
34 lines
1012 B
TypeScript
import { Injectable, Logger } from "@nestjs/common";
|
|
import { CreateReportDto } from "./dto/create-report.dto";
|
|
import { ReportsRepository } from "./repositories/reports.repository";
|
|
|
|
@Injectable()
|
|
export class ReportsService {
|
|
private readonly logger = new Logger(ReportsService.name);
|
|
|
|
constructor(private readonly reportsRepository: ReportsRepository) {}
|
|
|
|
async create(reporterId: string, data: CreateReportDto) {
|
|
this.logger.log(`Creating report from user ${reporterId}`);
|
|
return await this.reportsRepository.create({
|
|
reporterId,
|
|
contentId: data.contentId,
|
|
tagId: data.tagId,
|
|
reason: data.reason,
|
|
description: data.description,
|
|
});
|
|
}
|
|
|
|
async findAll(limit: number, offset: number) {
|
|
return await this.reportsRepository.findAll(limit, offset);
|
|
}
|
|
|
|
async updateStatus(
|
|
id: string,
|
|
status: "pending" | "reviewed" | "resolved" | "dismissed",
|
|
) {
|
|
this.logger.log(`Updating report ${id} status to ${status}`);
|
|
return await this.reportsRepository.updateStatus(id, status);
|
|
}
|
|
}
|