mirror of
https://github.com/Radarr/Radarr
synced 2025-01-03 13:54:29 +00:00
Fixed: Validate provider's settings in Test All endpoint
This commit is contained in:
parent
3191a883dc
commit
02518e2116
1 changed files with 9 additions and 2 deletions
|
@ -48,6 +48,7 @@ protected override TProviderResource GetResourceById(int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
[Produces("application/json")]
|
||||||
public List<TProviderResource> GetAll()
|
public List<TProviderResource> GetAll()
|
||||||
{
|
{
|
||||||
var providerDefinitions = _providerFactory.All();
|
var providerDefinitions = _providerFactory.All();
|
||||||
|
@ -165,6 +166,7 @@ private TProviderDefinition GetDefinition(TProviderResource providerResource, TP
|
||||||
public object DeleteProvider(int id)
|
public object DeleteProvider(int id)
|
||||||
{
|
{
|
||||||
_providerFactory.Delete(id);
|
_providerFactory.Delete(id);
|
||||||
|
|
||||||
return new { };
|
return new { };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ public virtual object DeleteProviders([FromBody] TBulkProviderResource resource)
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("schema")]
|
[HttpGet("schema")]
|
||||||
|
[Produces("application/json")]
|
||||||
public List<TProviderResource> GetTemplates()
|
public List<TProviderResource> GetTemplates()
|
||||||
{
|
{
|
||||||
var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();
|
var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();
|
||||||
|
@ -201,6 +204,7 @@ public List<TProviderResource> GetTemplates()
|
||||||
|
|
||||||
[SkipValidation(true, false)]
|
[SkipValidation(true, false)]
|
||||||
[HttpPost("test")]
|
[HttpPost("test")]
|
||||||
|
[Consumes("application/json")]
|
||||||
public object Test([FromBody] TProviderResource providerResource)
|
public object Test([FromBody] TProviderResource providerResource)
|
||||||
{
|
{
|
||||||
var existingDefinition = providerResource.Id > 0 ? _providerFactory.Find(providerResource.Id) : null;
|
var existingDefinition = providerResource.Id > 0 ? _providerFactory.Find(providerResource.Id) : null;
|
||||||
|
@ -222,12 +226,15 @@ public IActionResult TestAll()
|
||||||
|
|
||||||
foreach (var definition in providerDefinitions)
|
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
|
result.Add(new ProviderTestAllResult
|
||||||
{
|
{
|
||||||
Id = definition.Id,
|
Id = definition.Id,
|
||||||
ValidationFailures = validationResult.Errors.ToList()
|
ValidationFailures = validationFailures
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue