New: Device names for Join notifications

Closes #2364
This commit is contained in:
Mark McDowall 2018-01-12 19:14:21 -08:00
parent 8a6acd999a
commit 8e8da76467
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 @@ 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);
}

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 @@ 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));