From a90316b4d969eb2ce82bfa4e116e5cc61aa7ad03 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 15 May 2024 18:20:46 +0200 Subject: [PATCH] Replace UserId with User in NextUpQuery --- .../TV/TVSeriesManager.cs | 18 +++--------------- Jellyfin.Api/Controllers/TvShowsController.cs | 13 +++++++------ .../Entities/UserViewBuilder.cs | 2 +- MediaBrowser.Model/Querying/NextUpQuery.cs | 7 ++++--- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index c1a615666c..d92d954a6e 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -19,14 +19,12 @@ namespace Emby.Server.Implementations.TV { public class TVSeriesManager : ITVSeriesManager { - private readonly IUserManager _userManager; private readonly IUserDataManager _userDataManager; private readonly ILibraryManager _libraryManager; private readonly IServerConfigurationManager _configurationManager; - public TVSeriesManager(IUserManager userManager, IUserDataManager userDataManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager) + public TVSeriesManager(IUserDataManager userDataManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager) { - _userManager = userManager; _userDataManager = userDataManager; _libraryManager = libraryManager; _configurationManager = configurationManager; @@ -34,12 +32,7 @@ namespace Emby.Server.Implementations.TV public QueryResult GetNextUp(NextUpQuery query, DtoOptions options) { - var user = _userManager.GetUserById(query.UserId); - - if (user is null) - { - throw new ArgumentException("User not found"); - } + var user = query.User; string? presentationUniqueKey = null; if (!query.SeriesId.IsNullOrEmpty()) @@ -83,12 +76,7 @@ namespace Emby.Server.Implementations.TV public QueryResult GetNextUp(NextUpQuery request, BaseItem[] parentsFolders, DtoOptions options) { - var user = _userManager.GetUserById(request.UserId); - - if (user is null) - { - throw new ArgumentException("User not found"); - } + var user = request.User; string? presentationUniqueKey = null; int? limit = request.Limit; diff --git a/Jellyfin.Api/Controllers/TvShowsController.cs b/Jellyfin.Api/Controllers/TvShowsController.cs index 4264026670..914ccd7f93 100644 --- a/Jellyfin.Api/Controllers/TvShowsController.cs +++ b/Jellyfin.Api/Controllers/TvShowsController.cs @@ -90,7 +90,12 @@ public class TvShowsController : BaseJellyfinApiController [FromQuery] bool enableResumable = true, [FromQuery] bool enableRewatching = false) { - userId = RequestHelpers.GetUserId(User, userId); + var user = _userManager.GetUserById(RequestHelpers.GetUserId(User, userId)); + if (user is null) + { + return NotFound(); + } + var options = new DtoOptions { Fields = fields } .AddClientFields(User) .AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes); @@ -102,7 +107,7 @@ public class TvShowsController : BaseJellyfinApiController ParentId = parentId, SeriesId = seriesId, StartIndex = startIndex, - UserId = userId.Value, + User = user, EnableTotalRecordCount = enableTotalRecordCount, DisableFirstEpisode = disableFirstEpisode, NextUpDateCutoff = nextUpDateCutoff ?? DateTime.MinValue, @@ -111,10 +116,6 @@ public class TvShowsController : BaseJellyfinApiController }, options); - var user = userId.IsNullOrEmpty() - ? null - : _userManager.GetUserById(userId.Value); - var returnItems = _dtoService.GetBaseItemDtos(result.Items, options, user); return new QueryResult( diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 3a1d0c070b..2fda7ee6f7 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -337,7 +337,7 @@ namespace MediaBrowser.Controller.Entities { Limit = query.Limit, StartIndex = query.StartIndex, - UserId = query.User.Id + User = query.User }, parentFolders, query.DtoOptions); diff --git a/MediaBrowser.Model/Querying/NextUpQuery.cs b/MediaBrowser.Model/Querying/NextUpQuery.cs index 35353e6fa6..622c495261 100644 --- a/MediaBrowser.Model/Querying/NextUpQuery.cs +++ b/MediaBrowser.Model/Querying/NextUpQuery.cs @@ -2,6 +2,7 @@ #pragma warning disable CS1591 using System; +using Jellyfin.Data.Entities; using MediaBrowser.Model.Entities; namespace MediaBrowser.Model.Querying @@ -19,10 +20,10 @@ namespace MediaBrowser.Model.Querying } /// - /// Gets or sets the user id. + /// Gets or sets the user. /// - /// The user id. - public Guid UserId { get; set; } + /// The user. + public User User { get; set; } /// /// Gets or sets the parent identifier.