Fixed: Prowl notifications priority

Closes #4719
This commit is contained in:
Robin Dadswell 2021-11-02 03:29:18 +00:00 committed by GitHub
parent f58a2389bd
commit 85a143a1b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View File

@ -18,27 +18,27 @@ namespace NzbDrone.Core.Notifications.Prowl
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)
{
_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)
{
_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)
{
_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)
{
_prowlProxy.SendNotification(HEALTH_ISSUE_TITLE, message.Message, Settings.ApiKey, (ProwlPriority)Settings.Priority);
_prowlProxy.SendNotification(HEALTH_ISSUE_TITLE, message.Message, Settings);
}
public override ValidationResult Test()

View File

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Notifications.Prowl
{
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);
}
@ -25,19 +25,18 @@ namespace NzbDrone.Core.Notifications.Prowl
_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
{
var requestBuilder = new HttpRequestBuilder(PUSH_URL);
var request = requestBuilder.Post()
.AddFormParameter("apikey", apiKey)
.AddFormParameter("apikey", settings.ApiKey)
.AddFormParameter("application", BuildInfo.AppName)
.AddFormParameter("event", title)
.AddFormParameter("description", message)
.AddFormParameter("priority", priority)
.AddFormParameter("url", url)
.AddFormParameter("priority", settings.Priority)
.Build();
_httpClient.Post(request);
@ -46,7 +45,7 @@ namespace NzbDrone.Core.Notifications.Prowl
{
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);
}
@ -65,7 +64,7 @@ namespace NzbDrone.Core.Notifications.Prowl
const string title = "Test Notification";
const string body = "This is a test message from Sonarr";
SendNotification(title, body, settings.ApiKey);
SendNotification(title, body, settings);
}
catch (Exception ex)
{