From df593f486f2b71ae9d284fb67be75ebbc26839f9 Mon Sep 17 00:00:00 2001 From: Jeffrey Neer Date: Sat, 10 Nov 2018 16:51:14 -0600 Subject: [PATCH] New: Added priority levels to Join Notifications --- src/NzbDrone.Core/Notifications/Join/JoinPriority.cs | 11 +++++++++++ src/NzbDrone.Core/Notifications/Join/JoinProxy.cs | 1 + src/NzbDrone.Core/Notifications/Join/JoinSettings.cs | 9 +++++++++ src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 4 files changed, 22 insertions(+) create mode 100644 src/NzbDrone.Core/Notifications/Join/JoinPriority.cs diff --git a/src/NzbDrone.Core/Notifications/Join/JoinPriority.cs b/src/NzbDrone.Core/Notifications/Join/JoinPriority.cs new file mode 100644 index 000000000..9f2cab16f --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Join/JoinPriority.cs @@ -0,0 +1,11 @@ +namespace NzbDrone.Core.Notifications.Join +{ + public enum JoinPriority + { + Silent = -2, + Quiet = -1, + Normal = 0, + High = 1, + Emergency = 2 + } +} diff --git a/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs b/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs index 51666d959..c8d8bed6c 100644 --- a/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs +++ b/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs @@ -94,6 +94,7 @@ namespace NzbDrone.Core.Notifications.Join request.AddParameter("text", message); request.AddParameter("icon", "https://cdn.rawgit.com/Sonarr/Sonarr/develop/Logo/256.png"); // Use the Sonarr logo. request.AddParameter("smallicon", "https://cdn.rawgit.com/Sonarr/Sonarr/develop/Logo/96-Outline-White.png"); // 96x96px with outline at 88x88px on a transparent background. + request.AddParameter("priority", settings.Priority); var response = client.ExecuteAndValidate(request); var res = Json.Deserialize(response.Content); diff --git a/src/NzbDrone.Core/Notifications/Join/JoinSettings.cs b/src/NzbDrone.Core/Notifications/Join/JoinSettings.cs index ac305867f..797e7230a 100644 --- a/src/NzbDrone.Core/Notifications/Join/JoinSettings.cs +++ b/src/NzbDrone.Core/Notifications/Join/JoinSettings.cs @@ -16,6 +16,12 @@ namespace NzbDrone.Core.Notifications.Join public class JoinSettings : IProviderConfig { + + public JoinSettings() + { + Priority = (int)JoinPriority.Normal; + } + private static readonly JoinSettingsValidator Validator = new JoinSettingsValidator(); [FieldDefinition(0, Label = "API Key", HelpText = "The API Key from your Join account settings (click Join API button).", HelpLink = "https://joinjoaomgcd.appspot.com/")] @@ -27,6 +33,9 @@ namespace NzbDrone.Core.Notifications.Join [FieldDefinition(2, Label = "Device Names", HelpText = "Comma separated list of full or partial device names you'd like to send notifications to. If unset, all devices will receive notifications.", HelpLink = "https://joaoapps.com/join/api/")] public string DeviceNames { get; set; } + [FieldDefinition(3, Label = "Notification Priority", Type = FieldType.Select, SelectOptions = typeof(JoinPriority))] + public int Priority { get; set; } + public NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this)); diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 10b84d1bb..b1b48df42 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -911,6 +911,7 @@ +