New: Choose notification sound for PushOver

pull/4/head
Mark McDowall 11 years ago
parent 48a92696e9
commit 037127163f

@ -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 @@ namespace NzbDrone.Core.Notifications.Pushover
{
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)

@ -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 @@ namespace NzbDrone.Core.Notifications.Pushover
request.AddParameter("message", message);
request.AddParameter("priority", (int)priority);
if (!sound.IsNullOrWhiteSpace()) request.AddParameter("sound", sound);
client.ExecuteAndValidate(request);
}
@ -31,7 +35,7 @@ namespace NzbDrone.Core.Notifications.Pushover
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);
}
}
}

@ -27,6 +27,9 @@ namespace NzbDrone.Core.Notifications.Pushover
[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

@ -16,5 +16,6 @@ namespace NzbDrone.Core.Notifications.Pushover
public string ApiKey { get; set; }
public string UserKey { get; set; }
public int Priority { get; set; }
public string Sound { get; set; }
}
}

Loading…
Cancel
Save