|
|
|
@ -15,7 +15,6 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
|
|
|
|
|
|
|
|
|
public class NotifiarrProxy : INotifiarrProxy
|
|
|
|
|
{
|
|
|
|
|
private const string URL = "https://notifiarr.com/notifier.php";
|
|
|
|
|
private readonly IHttpClient _httpClient;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
@ -50,10 +49,19 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
|
|
|
|
}
|
|
|
|
|
catch (HttpException ex)
|
|
|
|
|
{
|
|
|
|
|
if (ex.Response.StatusCode == HttpStatusCode.Unauthorized)
|
|
|
|
|
switch ((int)ex.Response.StatusCode)
|
|
|
|
|
{
|
|
|
|
|
_logger.Error(ex, "API key is invalid: " + ex.Message);
|
|
|
|
|
return new ValidationFailure("APIKey", "API key is invalid");
|
|
|
|
|
case 401:
|
|
|
|
|
_logger.Error(ex, "API key is invalid: " + ex.Message);
|
|
|
|
|
return new ValidationFailure("APIKey", "API key is invalid");
|
|
|
|
|
case 400:
|
|
|
|
|
case 520:
|
|
|
|
|
case 521:
|
|
|
|
|
case 522:
|
|
|
|
|
case 523:
|
|
|
|
|
case 524:
|
|
|
|
|
_logger.Error(ex, "Unable to send test notification: " + ex.Message);
|
|
|
|
|
return new ValidationFailure("", "Unable to send test notification");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Error(ex, "Unable to send test message: " + ex.Message);
|
|
|
|
@ -70,8 +78,10 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var requestBuilder = new HttpRequestBuilder(URL).Post();
|
|
|
|
|
var url = settings.Environment == (int)NotifiarrEnvironment.Development ? "https://dev.notifiarr.com" : "https://notifiarr.com";
|
|
|
|
|
var requestBuilder = new HttpRequestBuilder(url + "/notifier.php").Post();
|
|
|
|
|
requestBuilder.AddFormParameter("api", settings.APIKey).Build();
|
|
|
|
|
requestBuilder.AddFormParameter("instanceName", settings.InstanceName).Build();
|
|
|
|
|
|
|
|
|
|
foreach (string key in message.Keys)
|
|
|
|
|
{
|
|
|
|
@ -84,10 +94,19 @@ namespace NzbDrone.Core.Notifications.Notifiarr
|
|
|
|
|
}
|
|
|
|
|
catch (HttpException ex)
|
|
|
|
|
{
|
|
|
|
|
if (ex.Response.StatusCode == HttpStatusCode.BadRequest)
|
|
|
|
|
switch ((int)ex.Response.StatusCode)
|
|
|
|
|
{
|
|
|
|
|
_logger.Error(ex, "API key is invalid");
|
|
|
|
|
throw;
|
|
|
|
|
case 401:
|
|
|
|
|
_logger.Error(ex, "API key is invalid");
|
|
|
|
|
throw;
|
|
|
|
|
case 400:
|
|
|
|
|
case 520:
|
|
|
|
|
case 521:
|
|
|
|
|
case 522:
|
|
|
|
|
case 523:
|
|
|
|
|
case 524:
|
|
|
|
|
_logger.Error(ex, "Unable to send notification");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new NotifiarrException("Unable to send notification", ex);
|
|
|
|
|