2013-05-19 23:17:32 +00:00
|
|
|
|
using System;
|
2013-10-12 18:44:40 +00:00
|
|
|
|
using FluentValidation;
|
2013-05-19 23:17:32 +00:00
|
|
|
|
using NzbDrone.Core.Annotations;
|
2013-09-21 06:39:26 +00:00
|
|
|
|
using NzbDrone.Core.ThingiProvider;
|
2015-03-17 04:33:34 +00:00
|
|
|
|
using NzbDrone.Core.Validation;
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
2013-05-27 05:44:54 +00:00
|
|
|
|
namespace NzbDrone.Core.Notifications.Email
|
2013-05-19 23:17:32 +00:00
|
|
|
|
{
|
2013-10-12 18:44:40 +00:00
|
|
|
|
public class EmailSettingsValidator : AbstractValidator<EmailSettings>
|
|
|
|
|
{
|
|
|
|
|
public EmailSettingsValidator()
|
|
|
|
|
{
|
|
|
|
|
RuleFor(c => c.Server).NotEmpty();
|
|
|
|
|
RuleFor(c => c.Port).GreaterThan(0);
|
|
|
|
|
RuleFor(c => c.From).NotEmpty();
|
|
|
|
|
RuleFor(c => c.To).NotEmpty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-21 06:39:26 +00:00
|
|
|
|
public class EmailSettings : IProviderConfig
|
2013-05-19 23:17:32 +00:00
|
|
|
|
{
|
2013-10-12 18:44:40 +00:00
|
|
|
|
private static readonly EmailSettingsValidator Validator = new EmailSettingsValidator();
|
|
|
|
|
|
2013-08-09 06:22:26 +00:00
|
|
|
|
public EmailSettings()
|
|
|
|
|
{
|
|
|
|
|
Port = 25;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-27 05:44:54 +00:00
|
|
|
|
[FieldDefinition(0, Label = "Server", HelpText = "Hostname or IP of Email server")]
|
2015-10-03 17:45:26 +00:00
|
|
|
|
public string Server { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
2013-05-27 05:44:54 +00:00
|
|
|
|
[FieldDefinition(1, Label = "Port")]
|
2015-10-03 17:45:26 +00:00
|
|
|
|
public int Port { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
2013-06-13 06:41:26 +00:00
|
|
|
|
[FieldDefinition(2, Label = "SSL", Type = FieldType.Checkbox)]
|
2015-10-03 17:45:26 +00:00
|
|
|
|
public bool Ssl { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
2013-05-27 05:44:54 +00:00
|
|
|
|
[FieldDefinition(3, Label = "Username")]
|
2015-10-03 17:45:26 +00:00
|
|
|
|
public string Username { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
2013-06-13 06:41:26 +00:00
|
|
|
|
[FieldDefinition(4, Label = "Password", Type = FieldType.Password)]
|
2015-10-03 17:45:26 +00:00
|
|
|
|
public string Password { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
2013-06-13 06:41:26 +00:00
|
|
|
|
[FieldDefinition(5, Label = "From Address")]
|
2015-10-03 17:45:26 +00:00
|
|
|
|
public string From { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
2013-05-27 05:44:54 +00:00
|
|
|
|
[FieldDefinition(6, Label = "Recipient Address")]
|
2015-10-03 17:45:26 +00:00
|
|
|
|
public string To { get; set; }
|
2013-05-19 23:17:32 +00:00
|
|
|
|
|
2015-03-17 04:33:34 +00:00
|
|
|
|
public NzbDroneValidationResult Validate()
|
2013-05-19 23:17:32 +00:00
|
|
|
|
{
|
2015-03-17 04:33:34 +00:00
|
|
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
2013-09-21 07:09:26 +00:00
|
|
|
|
}
|
2013-05-19 23:17:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|