fix: bypass ValidationPipe for multipart comments, auto-create uploads dir, expand client roles
- Use @Body() body: any in comment controller to skip global ValidationPipe which was rejecting multipart form bodies with forbidNonWhitelisted - Auto-create uploads/ directory on startup to prevent ENOENT on file uploads - Restrict file uploads to images only (remove pdf) - Allow technician/collector roles to update clients (was manager-only)
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { FileFieldsInterceptor } from '@nestjs/platform-express';
|
||||
import { CommentService } from './comment.service';
|
||||
import { CreateCommentDto } from './dto/create-comment.dto';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { TenantGuard } from '../common/guards/tenant.guard';
|
||||
@@ -39,10 +38,12 @@ export class CommentController {
|
||||
async create(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Param('ticketId') ticketId: string,
|
||||
@Body() body: CreateCommentDto,
|
||||
@Body() body: any,
|
||||
@UploadedFiles() files?: { files?: Express.Multer.File[] },
|
||||
) {
|
||||
const content = body.content;
|
||||
let content = body?.content;
|
||||
if (Array.isArray(content)) content = content[0];
|
||||
if (typeof content !== 'string') content = String(content ?? '');
|
||||
if (!content || content.length > 50000) {
|
||||
throw new BadRequestException('Content must be between 1 and 50000 characters');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user