mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-01-03 07:15:24 +00:00
New: Added priority levels to Join Notifications
This commit is contained in:
11
src/NzbDrone.Core/Notifications/Join/JoinPriority.cs
Normal file
11
src/NzbDrone.Core/Notifications/Join/JoinPriority.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace NzbDrone.Core.Notifications.Join
|
||||
{
|
||||
public enum JoinPriority
|
||||
{
|
||||
Silent = -2,
|
||||
Quiet = -1,
|
||||
Normal = 0,
|
||||
High = 1,
|
||||
Emergency = 2
|
||||
}
|
||||
}
|
||||
@@ -88,12 +88,13 @@ namespace NzbDrone.Core.Notifications.Join
|
||||
{
|
||||
request.AddParameter("deviceId", "group.all");
|
||||
}
|
||||
|
||||
|
||||
request.AddParameter("apikey", settings.ApiKey);
|
||||
request.AddParameter("title", title);
|
||||
request.AddParameter("text", message);
|
||||
request.AddParameter("icon", "https://cdn.rawgit.com/Lidarr/Lidarr/develop/Logo/256.png"); // Use the Lidarr logo.
|
||||
request.AddParameter("smallicon", "https://cdn.rawgit.com/Lidarr/Lidarr/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<JoinResponseModel>(response.Content);
|
||||
@@ -114,7 +115,7 @@ namespace NzbDrone.Core.Notifications.Join
|
||||
throw new JoinInvalidDeviceException(res.errorMessage);
|
||||
}
|
||||
// Oddly enough, rather than give us an "Invalid API key", the Join API seems to assume the key is valid,
|
||||
// but fails when doing a device lookup associated with that key.
|
||||
// but fails when doing a device lookup associated with that key.
|
||||
// In our case we are using "deviceIds" rather than "deviceId" so when the singular form error shows up
|
||||
// we know the API key was the fault.
|
||||
else if (res.errorMessage.Equals("No device to send message to"))
|
||||
|
||||
@@ -16,6 +16,11 @@ 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 +32,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));
|
||||
|
||||
@@ -884,6 +884,7 @@
|
||||
<Compile Include="Notifications\AlbumDownloadMessage.cs" />
|
||||
<Compile Include="Notifications\Join\JoinAuthException.cs" />
|
||||
<Compile Include="Notifications\Join\JoinInvalidDeviceException.cs" />
|
||||
<Compile Include="Notifications\Join\JoinPriority.cs" />
|
||||
<Compile Include="Notifications\Join\JoinResponseModel.cs" />
|
||||
<Compile Include="Notifications\Join\Join.cs" />
|
||||
<Compile Include="Notifications\Join\JoinException.cs" />
|
||||
|
||||
Reference in New Issue
Block a user