|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System;
|
|
|
|
|
using FluentValidation.Results;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
@ -16,19 +16,22 @@ namespace NzbDrone.Core.Notifications.Pushover
|
|
|
|
|
public class PushoverProxy : IPushoverProxy
|
|
|
|
|
{
|
|
|
|
|
private const string URL = "https://api.pushover.net/1/messages.json";
|
|
|
|
|
private readonly IRestClientFactory _restClientFactory;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public PushoverProxy(Logger logger)
|
|
|
|
|
public PushoverProxy(IRestClientFactory restClientFactory, Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_restClientFactory = restClientFactory;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SendNotification(string title, string message, PushoverSettings settings)
|
|
|
|
|
{
|
|
|
|
|
var client = RestClientFactory.BuildClient(URL);
|
|
|
|
|
var client = _restClientFactory.BuildClient(URL);
|
|
|
|
|
var request = new RestRequest(Method.POST);
|
|
|
|
|
request.AddParameter("token", settings.ApiKey);
|
|
|
|
|
request.AddParameter("user", settings.UserKey);
|
|
|
|
|
request.AddParameter("device", string.Join(",", settings.Devices));
|
|
|
|
|
request.AddParameter("title", title);
|
|
|
|
|
request.AddParameter("message", message);
|
|
|
|
|
request.AddParameter("priority", settings.Priority);
|
|
|
|
@ -52,13 +55,13 @@ namespace NzbDrone.Core.Notifications.Pushover
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const string title = "Test Notification";
|
|
|
|
|
const string body = "This is a test message from Radarr";
|
|
|
|
|
const string body = "This is a test message from Sonarr";
|
|
|
|
|
|
|
|
|
|
SendNotification(title, body, settings);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.Error(ex, "Unable to send test message: " + ex.Message);
|
|
|
|
|
_logger.Error(ex, "Unable to send test message");
|
|
|
|
|
return new ValidationFailure("ApiKey", "Unable to send test message");
|
|
|
|
|
}
|
|
|
|
|
|