Merge dev to main #1
@@ -7,6 +7,7 @@ import {
|
|||||||
UseGuards,
|
UseGuards,
|
||||||
UseInterceptors,
|
UseInterceptors,
|
||||||
UploadedFiles,
|
UploadedFiles,
|
||||||
|
BadRequestException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
import { AuthGuard } from '@nestjs/passport';
|
||||||
import { FileFieldsInterceptor } from '@nestjs/platform-express';
|
import { FileFieldsInterceptor } from '@nestjs/platform-express';
|
||||||
@@ -38,14 +39,18 @@ export class CommentController {
|
|||||||
async create(
|
async create(
|
||||||
@CurrentUser() user: CurrentUserPayload,
|
@CurrentUser() user: CurrentUserPayload,
|
||||||
@Param('ticketId') ticketId: string,
|
@Param('ticketId') ticketId: string,
|
||||||
@Body() dto: CreateCommentDto,
|
@Body() body: CreateCommentDto,
|
||||||
@UploadedFiles() files?: { files?: Express.Multer.File[] },
|
@UploadedFiles() files?: { files?: Express.Multer.File[] },
|
||||||
) {
|
) {
|
||||||
|
const content = body.content;
|
||||||
|
if (!content || content.length > 50000) {
|
||||||
|
throw new BadRequestException('Content must be between 1 and 50000 characters');
|
||||||
|
}
|
||||||
return this.commentService.create(
|
return this.commentService.create(
|
||||||
user.tenantId,
|
user.tenantId,
|
||||||
ticketId,
|
ticketId,
|
||||||
user.sub,
|
user.sub,
|
||||||
dto.content,
|
content,
|
||||||
files?.files,
|
files?.files,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
import { IsString, MinLength } from 'class-validator';
|
import {
|
||||||
|
IsString,
|
||||||
|
IsOptional,
|
||||||
|
IsArray,
|
||||||
|
MinLength,
|
||||||
|
MaxLength,
|
||||||
|
} from 'class-validator';
|
||||||
|
|
||||||
export class CreateCommentDto {
|
export class CreateCommentDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
@MinLength(1)
|
@MinLength(1)
|
||||||
content!: string;
|
@MaxLength(50000)
|
||||||
|
content: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsArray()
|
||||||
|
@IsString({ each: true })
|
||||||
|
files?: string[];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user