Skip to content

Commit

Permalink
Update reports dto
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemKolodko committed Jan 29, 2025
1 parent 4f41d05 commit 2a9cd13
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,6 @@ export class AppController {
throw new BadRequestException('No token or user address provided')
}

if(!dto.type) {
throw new BadRequestException('No type provided')
}

const existedReports = await this.appService.getReports(dto)
if(existedReports.length > 0) {
throw new BadRequestException('Report already exists')
Expand Down
10 changes: 9 additions & 1 deletion src/dto/report.dto.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ApiProperty } from '@nestjs/swagger';
import {IsNumber, IsOptional, IsString, Max} from 'class-validator';
import {IsNumber, IsOptional, IsString, Max, Min} from 'class-validator';
import {Transform, Type} from "class-transformer";

export class AddReportDto {
@ApiProperty({ type: Number, required: true })
@Type(() => Number)
@IsNumber()
@Min(-1)
@Max(3)
type: number;

@ApiProperty({ type: String, required: false })
Expand All @@ -28,6 +30,12 @@ export class AddReportDto {
@IsString()
@IsOptional()
reporterUserAddress?: string;

@ApiProperty({ type: String, required: false })
@Type(() => String)
@IsString()
@IsOptional()
details?: string;
}

export class GetReportsDto {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/report.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ReportEntity {
@Column({ nullable: true })
reporterUserAddress: string;

@ApiProperty()
@ApiProperty({ required: false })
@Column({ nullable: true })
details: string;

Expand Down

0 comments on commit 2a9cd13

Please sign in to comment.