mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-20 01:42:35 +01:00
Fixed: Validate provider's settings in Test All endpoint
This commit is contained in:
parent
3191a883dc
commit
02518e2116
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user