1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-01-10 23:29:53 +02:00

Prevent NullRef for empty ids in bulk endpoint

This commit is contained in:
Bogdan 2023-07-11 10:24:03 +03:00 committed by Mark McDowall
parent 2693ada7de
commit 0d3e9a2196
2 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,11 @@ public class ProviderBulkResource<T>
public List<int> Ids { get; set; }
public List<int> Tags { get; set; }
public ApplyTags ApplyTags { get; set; }
public ProviderBulkResource()
{
Ids = new List<int>();
}
}
public class ProviderBulkResourceMapper<TProviderBulkResource, TProviderDefinition>

View File

@ -106,6 +106,11 @@ public ActionResult<TProviderResource> UpdateProvider([FromBody] TProviderResour
[Produces("application/json")]
public ActionResult<TProviderResource> UpdateProvider([FromBody] TBulkProviderResource providerResource)
{
if (!providerResource.Ids.Any())
{
throw new BadRequestException("ids must be provided");
}
var definitionsToUpdate = _providerFactory.Get(providerResource.Ids).ToList();
foreach (var definition in definitionsToUpdate)