From ae886451800566937863e8c9a0c7164550b4aa30 Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 19 Feb 2018 08:18:36 +0100 Subject: [PATCH] Added: Device names for Join notifications (#2544) Closes #2364 --- src/NzbDrone.Core/Notifications/Join/JoinProxy.cs | 9 +++++++-- src/NzbDrone.Core/Notifications/Join/JoinSettings.cs | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs b/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs index e50feb89a..cafb16934 100644 --- a/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs +++ b/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs @@ -1,6 +1,7 @@ -using System; +using System; using FluentValidation.Results; using NLog; +using NzbDrone.Common.Extensions; using RestSharp; using NzbDrone.Core.Rest; using NzbDrone.Common.Serializer; @@ -75,7 +76,11 @@ namespace NzbDrone.Core.Notifications.Join var client = RestClientFactory.BuildClient(URL); - if (!string.IsNullOrEmpty(settings.DeviceIds)) + if (settings.DeviceNames.IsNotNullOrWhiteSpace()) + { + request.AddParameter("deviceNames", settings.DeviceNames); + } + else if (settings.DeviceIds.IsNotNullOrWhiteSpace()) { request.AddParameter("deviceIds", settings.DeviceIds); } diff --git a/src/NzbDrone.Core/Notifications/Join/JoinSettings.cs b/src/NzbDrone.Core/Notifications/Join/JoinSettings.cs index 29d750782..ac305867f 100644 --- a/src/NzbDrone.Core/Notifications/Join/JoinSettings.cs +++ b/src/NzbDrone.Core/Notifications/Join/JoinSettings.cs @@ -1,4 +1,4 @@ -using FluentValidation; +using FluentValidation; using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Notifications.Join public JoinSettingsValidator() { RuleFor(s => s.ApiKey).NotEmpty(); - RuleFor(s => s.DeviceIds).Matches(@"\A\S+\z").When(s => !string.IsNullOrEmpty(s.DeviceIds)); + RuleFor(s => s.DeviceIds).Empty().WithMessage("Use Device Names instead"); } } @@ -21,9 +21,12 @@ namespace NzbDrone.Core.Notifications.Join [FieldDefinition(0, Label = "API Key", HelpText = "The API Key from your Join account settings (click Join API button).", HelpLink = "https://joinjoaomgcd.appspot.com/")] public string ApiKey { get; set; } - [FieldDefinition(1, Label = "Device IDs", HelpText = "Comma separated list of Device IDs you'd like to send notifications to. If unset, all devices will receive notifications.", HelpLink = "https://joinjoaomgcd.appspot.com/")] + [FieldDefinition(1, Label = "Device IDs", HelpText = "Deprecated, use Device Names instead. Comma separated list of Device IDs you'd like to send notifications to. If unset, all devices will receive notifications.")] public string DeviceIds { get; set; } + [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; } + public NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this));