The Free Software Media System - Server Backend & API
Add dto for device options
Patrick Barron60ce0c9fa9a3
diff --git a/Jellyfin.Api/Controllers/DevicesController.cs b/Jellyfin.Api/Controllers/DevicesController.csindex 26b9a854da..ebe7b7584b 100644--- a/Jellyfin.Api/Controllers/DevicesController.cs+++ b/Jellyfin.Api/Controllers/DevicesController.cs@@ -2,6 +2,7 @@ using System;using System.ComponentModel.DataAnnotations;using System.Threading.Tasks;using Jellyfin.Api.Constants;+using Jellyfin.Data.Dtos;using Jellyfin.Data.Entities.Security;using Jellyfin.Data.Queries;using MediaBrowser.Controller.Devices;@@ -105,9 +106,9 @@ namespace Jellyfin.Api.Controllers[ProducesResponseType(StatusCodes.Status404NotFound)]public async Task<ActionResult> UpdateDeviceOptions([FromQuery, Required] string id,- [FromBody, Required] DeviceOptions deviceOptions)+ [FromBody, Required] DeviceOptionsDto deviceOptions){- await _deviceManager.UpdateDeviceOptions(id, deviceOptions).ConfigureAwait(false);+ await _deviceManager.UpdateDeviceOptions(id, deviceOptions.CustomName).ConfigureAwait(false);return NoContent();}diff --git a/Jellyfin.Data/Dtos/DeviceOptionsDto.cs b/Jellyfin.Data/Dtos/DeviceOptionsDto.csnew file mode 100644index 0000000000..392ef5ff4e--- /dev/null+++ b/Jellyfin.Data/Dtos/DeviceOptionsDto.cs@@ -0,0 +1,23 @@+namespace Jellyfin.Data.Dtos+{+ /// <summary>+ /// A dto representing custom options for a device.+ /// </summary>+ public class DeviceOptionsDto+ {+ /// <summary>+ /// Gets or sets the id.+ /// </summary>+ public int Id { get; set; }++ /// <summary>+ /// Gets or sets the device id.+ /// </summary>+ public string? DeviceId { get; set; }++ /// <summary>+ /// Gets or sets the custom name.+ /// </summary>+ public string? CustomName { get; set; }+ }+}diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.csindex ef0d5db09f..3d1bc30e8a 100644--- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs+++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs@@ -46,7 +46,7 @@ namespace Jellyfin.Server.Implementations.Devices}/// <inheritdoc />- public async Task UpdateDeviceOptions(string deviceId, DeviceOptions options)+ public async Task UpdateDeviceOptions(string deviceId, string deviceName){await using var dbContext = _dbProvider.CreateContext();var deviceOptions = await dbContext.DeviceOptions.AsQueryable().FirstOrDefaultAsync(dev => dev.DeviceId == deviceId).ConfigureAwait(false);@@ -56,10 +56,10 @@ namespace Jellyfin.Server.Implementations.DevicesdbContext.DeviceOptions.Add(deviceOptions);}- deviceOptions.CustomName = options.CustomName;+ deviceOptions.CustomName = deviceName;await dbContext.SaveChangesAsync().ConfigureAwait(false);- DeviceOptionsUpdated?.Invoke(this, new GenericEventArgs<Tuple<string, DeviceOptions>>(new Tuple<string, DeviceOptions>(deviceId, options)));+ DeviceOptionsUpdated?.Invoke(this, new GenericEventArgs<Tuple<string, DeviceOptions>>(new Tuple<string, DeviceOptions>(deviceId, deviceOptions)));}/// <inheritdoc />diff --git a/MediaBrowser.Controller/Devices/IDeviceManager.cs b/MediaBrowser.Controller/Devices/IDeviceManager.csindex 6ff4422d21..7e696c3b38 100644--- a/MediaBrowser.Controller/Devices/IDeviceManager.cs+++ b/MediaBrowser.Controller/Devices/IDeviceManager.cs@@ -70,7 +70,7 @@ namespace MediaBrowser.Controller.Devices/// </summary>bool CanAccessDevice(User user, string deviceId);- Task UpdateDeviceOptions(string deviceId, DeviceOptions options);+ Task UpdateDeviceOptions(string deviceId, string deviceName);Task<DeviceOptions> GetDeviceOptions(string deviceId);}