mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-24 22:55:21 -04:00
Fixed: (Apps) Ensure validation for test connection
This commit is contained in:
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using FluentValidation.Results;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Core.Applications.LazyLibrarian
|
||||
{
|
||||
@@ -139,11 +139,11 @@ namespace NzbDrone.Core.Applications.LazyLibrarian
|
||||
return new ValidationFailure("ApiKey", status.Error.Message);
|
||||
}
|
||||
|
||||
var indexers = GetIndexers(settings);
|
||||
GetIndexers(settings);
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
_logger.Error(ex, "Unable to send test message");
|
||||
_logger.Error(ex, "Unable to complete application test");
|
||||
return new ValidationFailure("BaseUrl", "Unable to complete application test");
|
||||
}
|
||||
catch (LazyLibrarianException ex)
|
||||
@@ -153,8 +153,8 @@ namespace NzbDrone.Core.Applications.LazyLibrarian
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Unable to send test message");
|
||||
return new ValidationFailure("", "Unable to send test message");
|
||||
_logger.Error(ex, "Unable to complete application test");
|
||||
return new ValidationFailure("", $"Unable to send test message. {ex.Message}");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -164,7 +164,9 @@ namespace NzbDrone.Core.Applications.LazyLibrarian
|
||||
{
|
||||
var baseUrl = settings.BaseUrl.TrimEnd('/');
|
||||
|
||||
var requestBuilder = new HttpRequestBuilder(baseUrl).Resource(resource)
|
||||
var requestBuilder = new HttpRequestBuilder(baseUrl)
|
||||
.Resource(resource)
|
||||
.Accept(HttpAccept.Json)
|
||||
.AddQueryParam("cmd", command)
|
||||
.AddQueryParam("apikey", settings.ApiKey);
|
||||
|
||||
@@ -191,9 +193,12 @@ namespace NzbDrone.Core.Applications.LazyLibrarian
|
||||
{
|
||||
var response = _httpClient.Execute(request);
|
||||
|
||||
var results = JsonConvert.DeserializeObject<TResource>(response.Content);
|
||||
if ((int)response.StatusCode >= 300)
|
||||
{
|
||||
throw new HttpException(response);
|
||||
}
|
||||
|
||||
return results;
|
||||
return Json.Deserialize<TResource>(response.Content);
|
||||
}
|
||||
|
||||
private int CalculatePriority(int indexerPriority) => ProwlarrHighestPriority - indexerPriority + 1;
|
||||
|
||||
Reference in New Issue
Block a user