aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Jellyfin.Api/Controllers/DevicesController.cs5
-rw-r--r--Jellyfin.Data/Dtos/DeviceOptionsDto.cs23
-rw-r--r--Jellyfin.Server.Implementations/Devices/DeviceManager.cs6
-rw-r--r--MediaBrowser.Controller/Devices/IDeviceManager.cs2
4 files changed, 30 insertions, 6 deletions
diff --git a/Jellyfin.Api/Controllers/DevicesController.cs b/Jellyfin.Api/Controllers/DevicesController.cs
index 26b9a854d..ebe7b7584 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.cs
new file mode 100644
index 000000000..392ef5ff4
--- /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.cs
index ef0d5db09..3d1bc30e8 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.Devices
dbContext.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.cs
index 6ff4422d2..7e696c3b3 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);
}