1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

New: Choose notification sound for PushOver

This commit is contained in:
Mark McDowall 2014-04-03 07:05:38 -07:00
parent 48a92696e9
commit 037127163f
4 changed files with 15 additions and 7 deletions

View File

@ -5,7 +5,7 @@ namespace NzbDrone.Core.Notifications.Pushover
public class Pushover : NotificationBase<PushoverSettings>
{
private readonly IPushoverProxy _pushoverProxy;
public Pushover(IPushoverProxy pushoverProxy)
{
_pushoverProxy = pushoverProxy;
@ -20,14 +20,14 @@ public override void OnGrab(string message)
{
const string title = "Episode Grabbed";
_pushoverProxy.SendNotification(title, message, Settings.ApiKey, Settings.UserKey, (PushoverPriority)Settings.Priority);
_pushoverProxy.SendNotification(title, message, Settings.ApiKey, Settings.UserKey, (PushoverPriority)Settings.Priority, Settings.Sound);
}
public override void OnDownload(DownloadMessage message)
{
const string title = "Episode Downloaded";
_pushoverProxy.SendNotification(title, message.Message, Settings.ApiKey, Settings.UserKey, (PushoverPriority)Settings.Priority);
_pushoverProxy.SendNotification(title, message.Message, Settings.ApiKey, Settings.UserKey, (PushoverPriority)Settings.Priority, Settings.Sound);
}
public override void AfterRename(Series series)

View File

@ -1,4 +1,5 @@
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Common;
using NzbDrone.Core.Messaging.Commands;
using RestSharp;
using NzbDrone.Core.Rest;
@ -6,14 +7,14 @@ namespace NzbDrone.Core.Notifications.Pushover
{
public interface IPushoverProxy
{
void SendNotification(string title, string message, string apiKey, string userKey, PushoverPriority priority);
void SendNotification(string title, string message, string apiKey, string userKey, PushoverPriority priority, string sound);
}
public class PushoverProxy : IPushoverProxy, IExecute<TestPushoverCommand>
{
private const string URL = "https://api.pushover.net/1/messages.json";
public void SendNotification(string title, string message, string apiKey, string userKey, PushoverPriority priority)
public void SendNotification(string title, string message, string apiKey, string userKey, PushoverPriority priority, string sound)
{
var client = new RestClient(URL);
var request = new RestRequest(Method.POST);
@ -23,6 +24,9 @@ public void SendNotification(string title, string message, string apiKey, string
request.AddParameter("message", message);
request.AddParameter("priority", (int)priority);
if (!sound.IsNullOrWhiteSpace()) request.AddParameter("sound", sound);
client.ExecuteAndValidate(request);
}
@ -31,7 +35,7 @@ public void Execute(TestPushoverCommand message)
const string title = "Test Notification";
const string body = "This is a test message from NzbDrone";
SendNotification(title, body, message.ApiKey, message.UserKey, (PushoverPriority)message.Priority);
SendNotification(title, body, message.ApiKey, message.UserKey, (PushoverPriority)message.Priority, message.Sound);
}
}
}

View File

@ -27,6 +27,9 @@ public class PushoverSettings : IProviderConfig
[FieldDefinition(2, Label = "Priority", Type = FieldType.Select, SelectOptions = typeof(PushoverPriority) )]
public Int32 Priority { get; set; }
[FieldDefinition(3, Label = "Sound", Type = FieldType.Textbox, HelpText = "Notification sound, leave blank to use the default", HelpLink = "https://pushover.net/api#sounds")]
public String Sound { get; set; }
public bool IsValid
{
get

View File

@ -16,5 +16,6 @@ public override bool SendUpdatesToClient
public string ApiKey { get; set; }
public string UserKey { get; set; }
public int Priority { get; set; }
public string Sound { get; set; }
}
}