The Free Software Media System - Server Backend & API
Remove unnecessary query class
Patrick Barrone1f708607786
diff --git a/Jellyfin.Api/Controllers/DevicesController.cs b/Jellyfin.Api/Controllers/DevicesController.csindex 99f8ede3ae..4cfae568ad 100644--- a/Jellyfin.Api/Controllers/DevicesController.cs+++ b/Jellyfin.Api/Controllers/DevicesController.cs@@ -51,8 +51,7 @@ namespace Jellyfin.Api.Controllers[ProducesResponseType(StatusCodes.Status200OK)]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.GetDevices(deviceQuery);+ return await _deviceManager.GetDevicesForUser(userId, supportsSync);}/// <summary>diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.csindex 4758f24f3b..bde8eb86ee 100644--- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs+++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs@@ -91,7 +91,7 @@ namespace Jellyfin.Server.Implementations.Devices}/// <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();var sessions = dbContext.Devices@@ -100,17 +100,14 @@ namespace Jellyfin.Server.Implementations.Devices.ThenByDescending(d => d.DateLastActivity).AsAsyncEnumerable();- // TODO: DeviceQuery doesn't seem to be used from client. Not even Swagger.- if (query.SupportsSync.HasValue)+ if (supportsSync.HasValue){- var val = query.SupportsSync.Value;-- sessions = sessions.Where(i => GetCapabilities(i.DeviceId).SupportsSync == val);+ sessions = sessions.Where(i => GetCapabilities(i.DeviceId).SupportsSync == supportsSync.Value);}- 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));}diff --git a/MediaBrowser.Controller/Devices/IDeviceManager.cs b/MediaBrowser.Controller/Devices/IDeviceManager.csindex 26afd93943..28612cea33 100644--- a/MediaBrowser.Controller/Devices/IDeviceManager.cs+++ b/MediaBrowser.Controller/Devices/IDeviceManager.cs@@ -41,9 +41,10 @@ namespace MediaBrowser.Controller.Devices/// <summary>/// Gets the devices./// </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>- Task<QueryResult<DeviceInfo>> GetDevices(DeviceQuery query);+ Task<QueryResult<DeviceInfo>> GetDevicesForUser(Guid? userId, bool? supportsSync);/// <summary>/// Determines whether this instance [can access device] the specified user identifier.diff --git a/MediaBrowser.Model/Devices/DeviceQuery.cs b/MediaBrowser.Model/Devices/DeviceQuery.csdeleted file mode 100644index 64e366a560..0000000000--- a/MediaBrowser.Model/Devices/DeviceQuery.cs+++ /dev/null@@ -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; }- }-}