From 489fb309b3cb6dadc9ceaf435ad0c74ade3b18b9 Mon Sep 17 00:00:00 2001 From: enlineawork Date: Mon, 7 Sep 2026 21:01:14 -0300 Subject: [PATCH] feat(f4): add superadmin SMTP settings DTO --- .../dto/update-smtp-settings.dto.ts | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 api-v3/src/inspection-reports/dto/update-smtp-settings.dto.ts diff --git a/api-v3/src/inspection-reports/dto/update-smtp-settings.dto.ts b/api-v3/src/inspection-reports/dto/update-smtp-settings.dto.ts new file mode 100644 index 0000000..8f70893 --- /dev/null +++ b/api-v3/src/inspection-reports/dto/update-smtp-settings.dto.ts @@ -0,0 +1,71 @@ +import { Transform, Type } from 'class-transformer'; +import { + IsBoolean, + IsEmail, + IsEnum, + IsInt, + IsOptional, + IsString, + Max, + MaxLength, + Min, + MinLength, +} from 'class-validator'; +import { SmtpSecurityMode } from '../../database/entities'; + +export class UpdateSmtpSettingsDto { + @Transform(({ value }) => typeof value === 'string' ? value.trim() : value) + @IsString() + @MinLength(1) + @MaxLength(255) + host!: string; + + @Type(() => Number) + @IsInt() + @Min(1) + @Max(65535) + port!: number; + + @IsEnum(SmtpSecurityMode) + securityMode!: SmtpSecurityMode; + + @IsOptional() + @Transform(({ value }) => typeof value === 'string' ? value.trim() || null : value) + @IsString() + @MaxLength(255) + username?: string | null; + + /** Omitir para conservar la clave actual; enviar null/cadena vacĂ­a para quitarla. */ + @IsOptional() + @IsString() + @MaxLength(1000) + password?: string | null; + + @Transform(({ value }) => typeof value === 'string' ? value.trim() : value) + @IsString() + @MinLength(1) + @MaxLength(200) + fromName!: string; + + @Transform(({ value }) => typeof value === 'string' ? value.trim().toLowerCase() : value) + @IsEmail() + @MaxLength(320) + fromEmail!: string; + + @IsOptional() + @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim().toLowerCase() : null) + @IsEmail() + @MaxLength(320) + replyTo?: string | null; + + @Transform(({ value }) => value === true || value === 'true') + @IsBoolean() + enabled!: boolean; +} + +export class TestSmtpSettingsDto { + @Transform(({ value }) => typeof value === 'string' ? value.trim().toLowerCase() : value) + @IsEmail() + @MaxLength(320) + email!: string; +}