mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-25 22:36:59 -04:00
New: Added support for Gotify notifications (#730)
* Added support for Gotify notifications * Removed non-supported features and adjusted priorities * Use string interpolation to build url * Rename a few variables and improve Url validation * Improve building of the Url, move validation to Gotify.cs (adapting changes by markus101 over at Sonarr) * Move validation from GotifyProxy.cs to here (adapting changes by markus101 over at Sonarr)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using FluentValidation;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Gotify
|
||||
{
|
||||
public class GotifySettingsValidator : AbstractValidator<GotifySettings>
|
||||
{
|
||||
public GotifySettingsValidator()
|
||||
{
|
||||
RuleFor(c => c.Server).IsValidUrl();
|
||||
RuleFor(c => c.AppToken).NotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public class GotifySettings : IProviderConfig
|
||||
{
|
||||
private static readonly GotifySettingsValidator Validator = new GotifySettingsValidator();
|
||||
|
||||
public GotifySettings()
|
||||
{
|
||||
Priority = 5;
|
||||
}
|
||||
|
||||
[FieldDefinition(0, Label = "Gotify Server", HelpText = "Gotify server URL, including http(s):// and port if needed")]
|
||||
public string Server { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "App Token", HelpText = "The Application Token generated by Gotify")]
|
||||
public string AppToken { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "Priority", Type = FieldType.Select, SelectOptions = typeof(GotifyPriority), HelpText = "Priority of the notification")]
|
||||
public int Priority { get; set; }
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user