From 259fe4522c4fdcd7467500780fc70ccd75108bf2 Mon Sep 17 00:00:00 2001 From: LJQ Date: Tue, 17 Oct 2023 17:25:41 +0800 Subject: [PATCH] Update /Device endpoint to return CustomName --- .../Devices/DeviceManager.cs | 10 +++++++++- MediaBrowser.Model/Devices/DeviceInfo.cs | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs index a4b4c19599..80abe01abc 100644 --- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs +++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs @@ -177,7 +177,7 @@ namespace Jellyfin.Server.Implementations.Devices .OrderByDescending(d => d.DateLastActivity) .ThenBy(d => d.DeviceId) .AsAsyncEnumerable(); - + IAsyncEnumerable deviceOptions = dbContext.DeviceOptions.AsAsyncEnumerable(); if (supportsSync.HasValue) { sessions = sessions.Where(i => GetCapabilities(i.DeviceId).SupportsSync == supportsSync.Value); @@ -195,6 +195,14 @@ namespace Jellyfin.Server.Implementations.Devices } var array = await sessions.Select(device => ToDeviceInfo(device)).ToArrayAsync().ConfigureAwait(false); + await foreach (var deviceOption in deviceOptions) + { + var deviceInfo = array.FirstOrDefault(d => d.Id.Equals(deviceOption.DeviceId, StringComparison.OrdinalIgnoreCase)); + if (deviceInfo != null) + { + deviceInfo.CustomName = deviceOption.CustomName; + } + } return new QueryResult(array); } diff --git a/MediaBrowser.Model/Devices/DeviceInfo.cs b/MediaBrowser.Model/Devices/DeviceInfo.cs index 7a1c7a7382..4962992a0a 100644 --- a/MediaBrowser.Model/Devices/DeviceInfo.cs +++ b/MediaBrowser.Model/Devices/DeviceInfo.cs @@ -15,6 +15,8 @@ namespace MediaBrowser.Model.Devices public string Name { get; set; } + public string CustomName { get; set; } + /// /// Gets or sets the access token. ///