mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-04-24 05:47:22 -04:00
New: Don't treat 400 responses from Notifiarr as errors
(cherry picked from commit 5eb420bbe12f59d0a5392abf3d351be28ca210e6)
This commit is contained in:
parent
b7e57f0c08
commit
c664eaa9b5
1 changed files with 11 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Net.Http;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.Notifications.Webhook;
|
||||
|
@ -14,10 +15,12 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
|||
{
|
||||
private const string URL = "https://notifiarr.com";
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public NotifiarrProxy(IHttpClient httpClient)
|
||||
public NotifiarrProxy(IHttpClient httpClient, Logger logger)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void SendNotification(WebhookPayload payload, NotifiarrSettings settings)
|
||||
|
@ -47,12 +50,17 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
|||
switch ((int)responseCode)
|
||||
{
|
||||
case 401:
|
||||
_logger.Warn("HTTP 401 - API key is invalid");
|
||||
throw new NotifiarrException("API key is invalid");
|
||||
case 400:
|
||||
throw new NotifiarrException("Unable to send notification. Ensure Prowlarr Integration is enabled & assigned a channel on Notifiarr");
|
||||
// 400 responses shouldn't be treated as an actual error because it's a misconfiguration
|
||||
// between Prowlarr and Notifiarr for a specific event, but shouldn't stop all events.
|
||||
_logger.Warn("HTTP 400 - Unable to send notification. Ensure Prowlarr Integration is enabled & assigned a channel on Notifiarr");
|
||||
break;
|
||||
case 502:
|
||||
case 503:
|
||||
case 504:
|
||||
_logger.Warn("Unable to send notification. Service Unavailable");
|
||||
throw new NotifiarrException("Unable to send notification. Service Unavailable", ex);
|
||||
case 520:
|
||||
case 521:
|
||||
|
@ -61,6 +69,7 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
|||
case 524:
|
||||
throw new NotifiarrException("Cloudflare Related HTTP Error - Unable to send notification", ex);
|
||||
default:
|
||||
_logger.Error(ex, "Unknown HTTP Error - Unable to send notification");
|
||||
throw new NotifiarrException("Unknown HTTP Error - Unable to send notification", ex);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue