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.
49 lines
1.6 KiB
49 lines
1.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using FluentValidation;
|
|
using NzbDrone.Core.Annotations;
|
|
using NzbDrone.Core.Validation;
|
|
|
|
namespace NzbDrone.Core.Notifications.Mailgun
|
|
{
|
|
public class MailGunSettingsValidator : AbstractValidator<MailgunSettings>
|
|
{
|
|
public MailGunSettingsValidator()
|
|
{
|
|
RuleFor(c => c.ApiKey).NotEmpty();
|
|
RuleFor(c => c.From).NotEmpty();
|
|
RuleFor(c => c.Recipients).NotEmpty();
|
|
}
|
|
}
|
|
|
|
public class MailgunSettings : NotificationBaseSettings
|
|
{
|
|
private static readonly MailGunSettingsValidator Validator = new MailGunSettingsValidator();
|
|
|
|
public MailgunSettings()
|
|
{
|
|
Recipients = Array.Empty<string>();
|
|
}
|
|
|
|
[FieldDefinition(0, Label = "API Key", HelpText = "The API key generated from MailGun")]
|
|
public string ApiKey { get; set; }
|
|
|
|
[FieldDefinition(1, Label = "Use EU Endpoint?", HelpText = "Use the EU MailGun endpoint", Type = FieldType.Checkbox)]
|
|
public bool UseEuEndpoint { get; set; }
|
|
|
|
[FieldDefinition(2, Label = "From Address")]
|
|
public string From { get; set; }
|
|
|
|
[FieldDefinition(3, Label = "Sender Domain")]
|
|
public string SenderDomain { get; set; }
|
|
|
|
[FieldDefinition(4, Label = "Recipient Address(es)", Type = FieldType.Tag, Placeholder = "example@email.com,example1@email.com")]
|
|
public IEnumerable<string> Recipients { get; set; }
|
|
|
|
public override NzbDroneValidationResult Validate()
|
|
{
|
|
return new NzbDroneValidationResult(Validator.Validate(this));
|
|
}
|
|
}
|
|
}
|