mirror of
https://github.com/Sonarr/Sonarr
synced 2026-05-09 05:40:53 +02:00
feat: Shift quality definition limits management to the backend
This update moves the minimum, maximum, and preferred quality limits to the backend, accessible via the new `/qualitydefinition/limits` endpoint. This change improves support for unofficial Sonarr API clients and enables a more flexible frontend.
This commit is contained in:
parent
87bd5e62f2
commit
039d7775ed
3 changed files with 23 additions and 0 deletions
11
src/NzbDrone.Core/Qualities/QualityDefinitionLimits.cs
Normal file
11
src/NzbDrone.Core/Qualities/QualityDefinitionLimits.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace NzbDrone.Core.Qualities;
|
||||
|
||||
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification =
|
||||
"Serializable properties of a DTO")]
|
||||
public record QualityDefinitionLimits
|
||||
{
|
||||
public int MinLimit => 0;
|
||||
public int MaxLimit => 1000;
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ public interface IQualityDefinitionService
|
|||
List<QualityDefinition> All();
|
||||
QualityDefinition GetById(int id);
|
||||
QualityDefinition Get(Quality quality);
|
||||
QualityDefinitionLimits GetLimits();
|
||||
}
|
||||
|
||||
public class QualityDefinitionService : IQualityDefinitionService, IExecute<ResetQualityDefinitionsCommand>, IHandle<ApplicationStartedEvent>
|
||||
|
|
@ -64,6 +65,11 @@ public QualityDefinition Get(Quality quality)
|
|||
return GetAll()[quality];
|
||||
}
|
||||
|
||||
public QualityDefinitionLimits GetLimits()
|
||||
{
|
||||
return new QualityDefinitionLimits();
|
||||
}
|
||||
|
||||
private void InsertMissingDefinitions()
|
||||
{
|
||||
var insertList = new List<QualityDefinition>();
|
||||
|
|
|
|||
|
|
@ -55,6 +55,12 @@ public object UpdateMany([FromBody] List<QualityDefinitionResource> resource)
|
|||
.ToResource());
|
||||
}
|
||||
|
||||
[HttpGet("limits")]
|
||||
public ActionResult<QualityDefinitionLimits> GetLimits()
|
||||
{
|
||||
return Ok(_qualityDefinitionService.GetLimits());
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public void Handle(CommandExecutedEvent message)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue