You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.7 KiB
57 lines
1.7 KiB
using FluentValidation;
|
|
using NzbDrone.Core.Annotations;
|
|
using NzbDrone.Core.ThingiProvider;
|
|
using NzbDrone.Core.Validation;
|
|
|
|
namespace NzbDrone.Core.Notifications.Email
|
|
{
|
|
public class EmailSettingsValidator : AbstractValidator<EmailSettings>
|
|
{
|
|
public EmailSettingsValidator()
|
|
{
|
|
RuleFor(c => c.Server).NotEmpty();
|
|
RuleFor(c => c.Port).InclusiveBetween(1, 65535);
|
|
RuleFor(c => c.From).NotEmpty();
|
|
RuleFor(c => c.To).NotEmpty();
|
|
}
|
|
}
|
|
|
|
public class EmailSettings : IProviderConfig
|
|
{
|
|
private static readonly EmailSettingsValidator Validator = new EmailSettingsValidator();
|
|
|
|
public EmailSettings()
|
|
{
|
|
Server = "smtp.gmail.com";
|
|
Port = 587;
|
|
Ssl = true;
|
|
}
|
|
|
|
[FieldDefinition(0, Label = "Server", HelpText = "Hostname or IP of Email server")]
|
|
public string Server { get; set; }
|
|
|
|
[FieldDefinition(1, Label = "Port")]
|
|
public int Port { get; set; }
|
|
|
|
[FieldDefinition(2, Label = "SSL", Type = FieldType.Checkbox)]
|
|
public bool Ssl { get; set; }
|
|
|
|
[FieldDefinition(3, Label = "Username")]
|
|
public string Username { get; set; }
|
|
|
|
[FieldDefinition(4, Label = "Password", Type = FieldType.Password)]
|
|
public string Password { get; set; }
|
|
|
|
[FieldDefinition(5, Label = "From Address")]
|
|
public string From { get; set; }
|
|
|
|
[FieldDefinition(6, Label = "Recipient Address")]
|
|
public string To { get; set; }
|
|
|
|
public NzbDroneValidationResult Validate()
|
|
{
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
}
|
|
}
|
|
}
|