mirror of https://github.com/Sonarr/Sonarr
parent
f58a2389bd
commit
85a143a1b6
|
@ -18,27 +18,27 @@ namespace NzbDrone.Core.Notifications.Prowl
|
||||||
|
|
||||||
public override void OnGrab(GrabMessage grabMessage)
|
public override void OnGrab(GrabMessage grabMessage)
|
||||||
{
|
{
|
||||||
_prowlProxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings.ApiKey, (ProwlPriority)Settings.Priority);
|
_prowlProxy.SendNotification(EPISODE_GRABBED_TITLE, grabMessage.Message, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDownload(DownloadMessage message)
|
public override void OnDownload(DownloadMessage message)
|
||||||
{
|
{
|
||||||
_prowlProxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings.ApiKey, (ProwlPriority)Settings.Priority);
|
_prowlProxy.SendNotification(EPISODE_DOWNLOADED_TITLE, message.Message, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEpisodeFileDelete(EpisodeDeleteMessage deleteMessage)
|
public override void OnEpisodeFileDelete(EpisodeDeleteMessage deleteMessage)
|
||||||
{
|
{
|
||||||
_prowlProxy.SendNotification(EPISODE_DELETED_TITLE, deleteMessage.Message, Settings.ApiKey, (ProwlPriority)Settings.Priority);
|
_prowlProxy.SendNotification(EPISODE_DELETED_TITLE, deleteMessage.Message, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSeriesDelete(SeriesDeleteMessage deleteMessage)
|
public override void OnSeriesDelete(SeriesDeleteMessage deleteMessage)
|
||||||
{
|
{
|
||||||
_prowlProxy.SendNotification(SERIES_DELETED_TITLE, deleteMessage.Message, Settings.ApiKey, (ProwlPriority)Settings.Priority);
|
_prowlProxy.SendNotification(SERIES_DELETED_TITLE, deleteMessage.Message, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnHealthIssue(HealthCheck.HealthCheck message)
|
public override void OnHealthIssue(HealthCheck.HealthCheck message)
|
||||||
{
|
{
|
||||||
_prowlProxy.SendNotification(HEALTH_ISSUE_TITLE, message.Message, Settings.ApiKey, (ProwlPriority)Settings.Priority);
|
_prowlProxy.SendNotification(HEALTH_ISSUE_TITLE, message.Message, Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ValidationResult Test()
|
public override ValidationResult Test()
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace NzbDrone.Core.Notifications.Prowl
|
||||||
{
|
{
|
||||||
public interface IProwlProxy
|
public interface IProwlProxy
|
||||||
{
|
{
|
||||||
void SendNotification(string title, string message, string apiKey, ProwlPriority priority = ProwlPriority.Normal, string url = null);
|
void SendNotification(string title, string message, ProwlSettings settings);
|
||||||
ValidationFailure Test(ProwlSettings settings);
|
ValidationFailure Test(ProwlSettings settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,19 +25,18 @@ namespace NzbDrone.Core.Notifications.Prowl
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendNotification(string title, string message, string apiKey, ProwlPriority priority = ProwlPriority.Normal, string url = null)
|
public void SendNotification(string title, string message, ProwlSettings settings)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var requestBuilder = new HttpRequestBuilder(PUSH_URL);
|
var requestBuilder = new HttpRequestBuilder(PUSH_URL);
|
||||||
|
|
||||||
var request = requestBuilder.Post()
|
var request = requestBuilder.Post()
|
||||||
.AddFormParameter("apikey", apiKey)
|
.AddFormParameter("apikey", settings.ApiKey)
|
||||||
.AddFormParameter("application", BuildInfo.AppName)
|
.AddFormParameter("application", BuildInfo.AppName)
|
||||||
.AddFormParameter("event", title)
|
.AddFormParameter("event", title)
|
||||||
.AddFormParameter("description", message)
|
.AddFormParameter("description", message)
|
||||||
.AddFormParameter("priority", priority)
|
.AddFormParameter("priority", settings.Priority)
|
||||||
.AddFormParameter("url", url)
|
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
_httpClient.Post(request);
|
_httpClient.Post(request);
|
||||||
|
@ -46,7 +45,7 @@ namespace NzbDrone.Core.Notifications.Prowl
|
||||||
{
|
{
|
||||||
if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
|
if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, "Apikey is invalid: {0}", apiKey);
|
_logger.Error(ex, "Apikey is invalid: {0}", settings.ApiKey);
|
||||||
throw new ProwlException("Apikey is invalid", ex);
|
throw new ProwlException("Apikey is invalid", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +64,7 @@ namespace NzbDrone.Core.Notifications.Prowl
|
||||||
const string title = "Test Notification";
|
const string title = "Test Notification";
|
||||||
const string body = "This is a test message from Sonarr";
|
const string body = "This is a test message from Sonarr";
|
||||||
|
|
||||||
SendNotification(title, body, settings.ApiKey);
|
SendNotification(title, body, settings);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue