import {
  IsString,
  IsInt,
  IsOptional,
  IsIn,
  IsEmail,
  Min,
  Max,
} from 'class-validator';

export class UpsertEmailSettingsDto {
  @IsString()
  smtp_host: string;

  @IsInt()
  @Min(1)
  @Max(65535)
  smtp_port: number;

  @IsString()
  smtp_username: string;

  /** Optional on update — omit to keep the stored password. */
  @IsOptional()
  @IsString()
  smtp_password?: string;

  @IsIn(['ssl', 'tls'])
  smtp_encryption: 'ssl' | 'tls';

  @IsEmail()
  from_email: string;

  @IsOptional()
  @IsString()
  from_name?: string;

  /** null / omitted => generic sender, not tied to a user */
  @IsOptional()
  @IsInt()
  user_id?: number | null;
}

export class SendTestDto {
  @IsEmail()
  to: string;
}
