63 lines
2.6 KiB
TypeScript
63 lines
2.6 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { IsIn, IsOptional, IsString } from 'class-validator';
|
|
|
|
const IMAGE_TYPES = ['image/jpeg', 'image/png', 'image/webp', 'image/gif'] as const;
|
|
|
|
const DOCUMENT_ATTACHMENT_TYPES = [
|
|
...IMAGE_TYPES,
|
|
'application/pdf',
|
|
'application/msword',
|
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
'application/vnd.ms-excel',
|
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
'application/vnd.ms-powerpoint',
|
|
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
'text/plain',
|
|
'application/rtf',
|
|
'application/vnd.oasis.opendocument.text'
|
|
] as const;
|
|
|
|
export class AvatarUploadDto {
|
|
@ApiProperty({ description: 'MIME-тип изображения', example: 'image/jpeg', enum: IMAGE_TYPES })
|
|
@IsString({ message: 'Укажите MIME-тип изображения' })
|
|
@IsIn([...IMAGE_TYPES], { message: 'Допустимы только JPEG, PNG, WEBP или GIF' })
|
|
contentType!: string;
|
|
}
|
|
|
|
export class ConfirmAvatarDto {
|
|
@ApiProperty({ description: 'Ключ объекта в MinIO после загрузки', example: 'avatars/uuid/photo.jpg' })
|
|
@IsString({ message: 'Ключ хранилища должен быть строкой' })
|
|
storageKey!: string;
|
|
}
|
|
|
|
export class DocumentPhotoUploadDto {
|
|
@ApiProperty({ description: 'MIME-тип файла', example: 'application/pdf', enum: DOCUMENT_ATTACHMENT_TYPES })
|
|
@IsString({ message: 'Укажите MIME-тип файла' })
|
|
@IsIn([...DOCUMENT_ATTACHMENT_TYPES], {
|
|
message: 'Допустимы изображения, PDF, Word, Excel, PowerPoint, TXT и ODT'
|
|
})
|
|
contentType!: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Имя файла для определения расширения', example: 'passport.pdf' })
|
|
@IsOptional()
|
|
@IsString({ message: 'Имя файла должно быть строкой' })
|
|
fileName?: string;
|
|
}
|
|
|
|
export class ChatMediaUploadDto {
|
|
@ApiProperty({ description: 'MIME-тип файла', example: 'audio/webm' })
|
|
@IsString({ message: 'Укажите MIME-тип файла' })
|
|
contentType!: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Имя файла для определения расширения', example: 'voice.webm' })
|
|
@IsOptional()
|
|
@IsString({ message: 'Имя файла должно быть строкой' })
|
|
fileName?: string;
|
|
}
|
|
|
|
export class UpdateAvatarStorageDto {
|
|
@ApiProperty({ description: 'Ключ объекта в MinIO', example: 'avatars/uuid/photo.jpg' })
|
|
@IsString({ message: 'Ключ хранилища должен быть строкой' })
|
|
storageKey!: string;
|
|
}
|