1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Added: Device names for Join notifications (#2544)

Closes #2364
This commit is contained in:
Qstick 2018-02-19 08:18:36 +01:00 committed by Leonardo Galli
parent 8519b64947
commit ae88645180
2 changed files with 13 additions and 5 deletions

View File

@ -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 @@ private void SendNotification(string title, string message, RestRequest request,
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);
}

View File

@ -1,4 +1,4 @@
using FluentValidation;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@ -10,7 +10,7 @@ public class JoinSettingsValidator : AbstractValidator<JoinSettings>
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 @@ public class JoinSettings : IProviderConfig
[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));