diff options
| author | Claus Vium <cvium@users.noreply.github.com> | 2020-12-03 07:51:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-03 07:51:02 +0100 |
| commit | e042572588592f488aa00853ace5cb21d68293ec (patch) | |
| tree | 794d72c767e6d74fecd23ce012aa5d6a0dfffecd /Jellyfin.Api/Controllers/FilterController.cs | |
| parent | ea20f05de41feb6ba876bc5a17f0d62d419fe04f (diff) | |
| parent | 09b1e571f4e4dad19495e8873a5bc712a3bf9b7c (diff) | |
Merge pull request #4633 from crobibero/guid-params
Use Guid as API parameter type where possible
Diffstat (limited to 'Jellyfin.Api/Controllers/FilterController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/FilterController.cs | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/Jellyfin.Api/Controllers/FilterController.cs b/Jellyfin.Api/Controllers/FilterController.cs index 31cb9e273..1c0f1c1df 100644 --- a/Jellyfin.Api/Controllers/FilterController.cs +++ b/Jellyfin.Api/Controllers/FilterController.cs @@ -50,33 +50,24 @@ namespace Jellyfin.Api.Controllers [ProducesResponseType(StatusCodes.Status200OK)] public ActionResult<QueryFiltersLegacy> GetQueryFiltersLegacy( [FromQuery] Guid? userId, - [FromQuery] string? parentId, + [FromQuery] Guid? parentId, [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes, [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes) { - var parentItem = string.IsNullOrEmpty(parentId) - ? null - : _libraryManager.GetItemById(parentId); - var user = userId.HasValue && !userId.Equals(Guid.Empty) ? _userManager.GetUserById(userId.Value) : null; - if (includeItemTypes.Length == 1 - && (string.Equals(includeItemTypes[0], nameof(BoxSet), StringComparison.OrdinalIgnoreCase) - || string.Equals(includeItemTypes[0], nameof(Playlist), StringComparison.OrdinalIgnoreCase) - || string.Equals(includeItemTypes[0], nameof(Trailer), StringComparison.OrdinalIgnoreCase) - || string.Equals(includeItemTypes[0], "Program", StringComparison.OrdinalIgnoreCase))) + BaseItem? item = null; + if (includeItemTypes.Length != 1 + || !(string.Equals(includeItemTypes[0], nameof(BoxSet), StringComparison.OrdinalIgnoreCase) + || string.Equals(includeItemTypes[0], nameof(Playlist), StringComparison.OrdinalIgnoreCase) + || string.Equals(includeItemTypes[0], nameof(Trailer), StringComparison.OrdinalIgnoreCase) + || string.Equals(includeItemTypes[0], "Program", StringComparison.OrdinalIgnoreCase))) { - parentItem = null; + item = _libraryManager.GetParentItem(parentId, user?.Id); } - var item = string.IsNullOrEmpty(parentId) - ? user == null - ? _libraryManager.RootFolder - : _libraryManager.GetUserRootFolder() - : parentItem; - var query = new InternalItemsQuery { User = user, @@ -140,7 +131,7 @@ namespace Jellyfin.Api.Controllers [ProducesResponseType(StatusCodes.Status200OK)] public ActionResult<QueryFilters> GetQueryFilters( [FromQuery] Guid? userId, - [FromQuery] string? parentId, + [FromQuery] Guid? parentId, [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes, [FromQuery] bool? isAiring, [FromQuery] bool? isMovie, @@ -150,14 +141,11 @@ namespace Jellyfin.Api.Controllers [FromQuery] bool? isSeries, [FromQuery] bool? recursive) { - var parentItem = string.IsNullOrEmpty(parentId) - ? null - : _libraryManager.GetItemById(parentId); - var user = userId.HasValue && !userId.Equals(Guid.Empty) ? _userManager.GetUserById(userId.Value) : null; + BaseItem? parentItem = null; if (includeItemTypes.Length == 1 && (string.Equals(includeItemTypes[0], nameof(BoxSet), StringComparison.OrdinalIgnoreCase) || string.Equals(includeItemTypes[0], nameof(Playlist), StringComparison.OrdinalIgnoreCase) @@ -166,6 +154,10 @@ namespace Jellyfin.Api.Controllers { parentItem = null; } + else if (parentId.HasValue) + { + parentItem = _libraryManager.GetItemById(parentId.Value); + } var filters = new QueryFilters(); var genreQuery = new InternalItemsQuery(user) |
