Replace UserId with User in UserViewQuery
This commit is contained in:
parent
c680dbb53e
commit
09f4477510
|
@ -1530,7 +1530,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
var userViews = UserViewManager.GetUserViews(new UserViewQuery
|
var userViews = UserViewManager.GetUserViews(new UserViewQuery
|
||||||
{
|
{
|
||||||
UserId = user.Id,
|
User = user,
|
||||||
IncludeHidden = true,
|
IncludeHidden = true,
|
||||||
IncludeExternalContent = allowExternalContent
|
IncludeExternalContent = allowExternalContent
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,6 @@ using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Model.Channels;
|
using MediaBrowser.Model.Channels;
|
||||||
using MediaBrowser.Model.Entities;
|
|
||||||
using MediaBrowser.Model.Globalization;
|
using MediaBrowser.Model.Globalization;
|
||||||
using MediaBrowser.Model.Library;
|
using MediaBrowser.Model.Library;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
|
@ -27,17 +26,15 @@ namespace Emby.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly ILocalizationManager _localizationManager;
|
private readonly ILocalizationManager _localizationManager;
|
||||||
private readonly IUserManager _userManager;
|
|
||||||
|
|
||||||
private readonly IChannelManager _channelManager;
|
private readonly IChannelManager _channelManager;
|
||||||
private readonly ILiveTvManager _liveTvManager;
|
private readonly ILiveTvManager _liveTvManager;
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IUserManager userManager, IChannelManager channelManager, ILiveTvManager liveTvManager, IServerConfigurationManager config)
|
public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IChannelManager channelManager, ILiveTvManager liveTvManager, IServerConfigurationManager config)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_localizationManager = localizationManager;
|
_localizationManager = localizationManager;
|
||||||
_userManager = userManager;
|
|
||||||
_channelManager = channelManager;
|
_channelManager = channelManager;
|
||||||
_liveTvManager = liveTvManager;
|
_liveTvManager = liveTvManager;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
@ -45,11 +42,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
public Folder[] GetUserViews(UserViewQuery query)
|
public Folder[] GetUserViews(UserViewQuery query)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(query.UserId);
|
var user = query.User;
|
||||||
if (user is null)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("User id specified in the query does not exist.", nameof(query));
|
|
||||||
}
|
|
||||||
|
|
||||||
var folders = _libraryManager.GetUserRootFolder()
|
var folders = _libraryManager.GetUserRootFolder()
|
||||||
.GetChildren(user, true)
|
.GetChildren(user, true)
|
||||||
|
@ -125,14 +118,14 @@ namespace Emby.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
var channelResult = _channelManager.GetChannelsInternalAsync(new ChannelQuery
|
var channelResult = _channelManager.GetChannelsInternalAsync(new ChannelQuery
|
||||||
{
|
{
|
||||||
UserId = query.UserId
|
UserId = user.Id
|
||||||
}).GetAwaiter().GetResult();
|
}).GetAwaiter().GetResult();
|
||||||
|
|
||||||
var channels = channelResult.Items;
|
var channels = channelResult.Items;
|
||||||
|
|
||||||
list.AddRange(channels);
|
list.AddRange(channels);
|
||||||
|
|
||||||
if (_liveTvManager.GetEnabledUsers().Select(i => i.Id).Contains(query.UserId))
|
if (_liveTvManager.GetEnabledUsers().Select(i => i.Id).Contains(user.Id))
|
||||||
{
|
{
|
||||||
list.Add(_liveTvManager.GetInternalLiveTvFolder(CancellationToken.None));
|
list.Add(_liveTvManager.GetInternalLiveTvFolder(CancellationToken.None));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ using Jellyfin.Api.Helpers;
|
||||||
using Jellyfin.Api.ModelBinders;
|
using Jellyfin.Api.ModelBinders;
|
||||||
using Jellyfin.Api.Models.UserViewDtos;
|
using Jellyfin.Api.Models.UserViewDtos;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
@ -69,8 +70,9 @@ public class UserViewsController : BaseJellyfinApiController
|
||||||
[FromQuery] bool includeHidden = false)
|
[FromQuery] bool includeHidden = false)
|
||||||
{
|
{
|
||||||
userId = RequestHelpers.GetUserId(User, userId);
|
userId = RequestHelpers.GetUserId(User, userId);
|
||||||
|
var user = _userManager.GetUserById(userId.Value) ?? throw new ResourceNotFoundException();
|
||||||
|
|
||||||
var query = new UserViewQuery { UserId = userId.Value, IncludeHidden = includeHidden };
|
var query = new UserViewQuery { User = user, IncludeHidden = includeHidden };
|
||||||
|
|
||||||
if (includeExternalContent.HasValue)
|
if (includeExternalContent.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -87,8 +89,6 @@ public class UserViewsController : BaseJellyfinApiController
|
||||||
var dtoOptions = new DtoOptions().AddClientFields(User);
|
var dtoOptions = new DtoOptions().AddClientFields(User);
|
||||||
dtoOptions.Fields = [..dtoOptions.Fields, ItemFields.PrimaryImageAspectRatio, ItemFields.DisplayPreferencesId];
|
dtoOptions.Fields = [..dtoOptions.Fields, ItemFields.PrimaryImageAspectRatio, ItemFields.DisplayPreferencesId];
|
||||||
|
|
||||||
var user = _userManager.GetUserById(userId.Value);
|
|
||||||
|
|
||||||
var dtos = Array.ConvertAll(folders, i => _dtoService.GetBaseItemDto(i, dtoOptions, user));
|
var dtos = Array.ConvertAll(folders, i => _dtoService.GetBaseItemDto(i, dtoOptions, user));
|
||||||
|
|
||||||
return new QueryResult<BaseItemDto>(dtos);
|
return new QueryResult<BaseItemDto>(dtos);
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
var result = UserViewManager.GetUserViews(new UserViewQuery
|
var result = UserViewManager.GetUserViews(new UserViewQuery
|
||||||
{
|
{
|
||||||
UserId = query.User.Id,
|
User = query.User,
|
||||||
PresetViews = query.PresetViews
|
PresetViews = query.PresetViews
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Jellyfin.Data.Entities;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Library
|
namespace MediaBrowser.Model.Library
|
||||||
|
@ -14,10 +15,10 @@ namespace MediaBrowser.Model.Library
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the user identifier.
|
/// Gets or sets the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user identifier.</value>
|
/// <value>The user.</value>
|
||||||
public Guid UserId { get; set; }
|
public required User User { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether [include external content].
|
/// Gets or sets a value indicating whether [include external content].
|
||||||
|
|
Loading…
Reference in New Issue
Block a user