mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Remove unnecessary query class
This commit is contained in:
parent
a225f34796
commit
e1f7086077
@ -51,8 +51,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<QueryResult<DeviceInfo>>> GetDevices([FromQuery] bool? supportsSync, [FromQuery] Guid? userId)
|
public async Task<ActionResult<QueryResult<DeviceInfo>>> GetDevices([FromQuery] bool? supportsSync, [FromQuery] Guid? userId)
|
||||||
{
|
{
|
||||||
var deviceQuery = new DeviceQuery { SupportsSync = supportsSync, UserId = userId ?? Guid.Empty };
|
return await _deviceManager.GetDevicesForUser(userId, supportsSync);
|
||||||
return await _deviceManager.GetDevices(deviceQuery);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -91,7 +91,7 @@ namespace Jellyfin.Server.Implementations.Devices
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<QueryResult<DeviceInfo>> GetDevices(DeviceQuery query)
|
public async Task<QueryResult<DeviceInfo>> GetDevicesForUser(Guid? userId, bool? supportsSync)
|
||||||
{
|
{
|
||||||
await using var dbContext = _dbProvider.CreateContext();
|
await using var dbContext = _dbProvider.CreateContext();
|
||||||
var sessions = dbContext.Devices
|
var sessions = dbContext.Devices
|
||||||
@ -100,17 +100,14 @@ namespace Jellyfin.Server.Implementations.Devices
|
|||||||
.ThenByDescending(d => d.DateLastActivity)
|
.ThenByDescending(d => d.DateLastActivity)
|
||||||
.AsAsyncEnumerable();
|
.AsAsyncEnumerable();
|
||||||
|
|
||||||
// TODO: DeviceQuery doesn't seem to be used from client. Not even Swagger.
|
if (supportsSync.HasValue)
|
||||||
if (query.SupportsSync.HasValue)
|
|
||||||
{
|
{
|
||||||
var val = query.SupportsSync.Value;
|
sessions = sessions.Where(i => GetCapabilities(i.DeviceId).SupportsSync == supportsSync.Value);
|
||||||
|
|
||||||
sessions = sessions.Where(i => GetCapabilities(i.DeviceId).SupportsSync == val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!query.UserId.Equals(Guid.Empty))
|
if (userId.HasValue)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(query.UserId);
|
var user = _userManager.GetUserById(userId.Value);
|
||||||
|
|
||||||
sessions = sessions.Where(i => CanAccessDevice(user, i.DeviceId));
|
sessions = sessions.Where(i => CanAccessDevice(user, i.DeviceId));
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,10 @@ namespace MediaBrowser.Controller.Devices
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the devices.
|
/// Gets the devices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="query">The query.</param>
|
/// <param name="userId">The user's id, or <c>null</c>.</param>
|
||||||
|
/// <param name="supportsSync">A value indicating whether the device supports sync, or <c>null</c>.</param>
|
||||||
/// <returns>IEnumerable<DeviceInfo>.</returns>
|
/// <returns>IEnumerable<DeviceInfo>.</returns>
|
||||||
Task<QueryResult<DeviceInfo>> GetDevices(DeviceQuery query);
|
Task<QueryResult<DeviceInfo>> GetDevicesForUser(Guid? userId, bool? supportsSync);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether this instance [can access device] the specified user identifier.
|
/// Determines whether this instance [can access device] the specified user identifier.
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Devices
|
|
||||||
{
|
|
||||||
public class DeviceQuery
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether [supports synchronize].
|
|
||||||
/// </summary>
|
|
||||||
/// <value><c>null</c> if [supports synchronize] contains no value, <c>true</c> if [supports synchronize]; otherwise, <c>false</c>.</value>
|
|
||||||
public bool? SupportsSync { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the user identifier.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The user identifier.</value>
|
|
||||||
public Guid UserId { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user