1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-22 07:52:34 +00:00

Fixed: Validate provider's settings in Test All endpoint

This commit is contained in:
Bogdan 2024-04-16 11:39:35 +03:00
parent 3191a883dc
commit 02518e2116

View file

@ -48,6 +48,7 @@ protected override TProviderResource GetResourceById(int id)
}
[HttpGet]
[Produces("application/json")]
public List<TProviderResource> GetAll()
{
var providerDefinitions = _providerFactory.All();
@ -165,6 +166,7 @@ private TProviderDefinition GetDefinition(TProviderResource providerResource, TP
public object DeleteProvider(int id)
{
_providerFactory.Delete(id);
return new { };
}
@ -178,6 +180,7 @@ public virtual object DeleteProviders([FromBody] TBulkProviderResource resource)
}
[HttpGet("schema")]
[Produces("application/json")]
public List<TProviderResource> GetTemplates()
{
var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();
@ -201,6 +204,7 @@ public List<TProviderResource> GetTemplates()
[SkipValidation(true, false)]
[HttpPost("test")]
[Consumes("application/json")]
public object Test([FromBody] TProviderResource providerResource)
{
var existingDefinition = providerResource.Id > 0 ? _providerFactory.Find(providerResource.Id) : null;
@ -222,12 +226,15 @@ public IActionResult TestAll()
foreach (var definition in providerDefinitions)
{
var validationResult = _providerFactory.Test(definition);
var validationFailures = new List<ValidationFailure>();
validationFailures.AddRange(definition.Settings.Validate().Errors);
validationFailures.AddRange(_providerFactory.Test(definition).Errors);
result.Add(new ProviderTestAllResult
{
Id = definition.Id,
ValidationFailures = validationResult.Errors.ToList()
ValidationFailures = validationFailures
});
}