The Free Software Media System - Server Backend & API
feat: implement CommaDelimitedArrayModelBinderProvider
[email protected]9aad77228814
diff --git a/Jellyfin.Api/Controllers/SessionController.cs b/Jellyfin.Api/Controllers/SessionController.csindex 68cec14151..3dbf7ba0b7 100644--- a/Jellyfin.Api/Controllers/SessionController.cs+++ b/Jellyfin.Api/Controllers/SessionController.cs@@ -379,7 +379,7 @@ namespace Jellyfin.Api.Controllerspublic ActionResult PostCapabilities([FromQuery] string? id,[FromQuery] string? playableMediaTypes,- [FromQuery][ModelBinder(typeof(CommaDelimitedArrayModelBinder))] GeneralCommandType[] supportedCommands,+ [FromQuery] GeneralCommandType[] supportedCommands,[FromQuery] bool supportsMediaControl = false,[FromQuery] bool supportsSync = false,[FromQuery] bool supportsPersistentIdentifier = true)diff --git a/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinderProvider.cs b/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinderProvider.csnew file mode 100644index 0000000000..b9785a73b8--- /dev/null+++ b/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinderProvider.cs@@ -0,0 +1,29 @@+using System;+using System.Collections.Generic;+using System.Text;+using Microsoft.AspNetCore.Mvc.ModelBinding;++namespace Jellyfin.Api.ModelBinders+{+ /// <summary>+ /// Comma delimited array model binder provider.+ /// </summary>+ public class CommaDelimitedArrayModelBinderProvider : IModelBinderProvider+ {+ private readonly IModelBinder _binder;++ /// <summary>+ /// Initializes a new instance of the <see cref="CommaDelimitedArrayModelBinderProvider"/> class.+ /// </summary>+ public CommaDelimitedArrayModelBinderProvider()+ {+ _binder = new CommaDelimitedArrayModelBinder();+ }++ /// <inheritdoc />+ public IModelBinder? GetBinder(ModelBinderProviderContext context)+ {+ return context.Metadata.ModelType.IsArray ? _binder : null;+ }+ }+}diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.csindex 5bcf6d5f07..f867143df6 100644--- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs+++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs@@ -16,6 +16,7 @@ using Jellyfin.Api.Auth.LocalAccessPolicy;using Jellyfin.Api.Auth.RequiresElevationPolicy;using Jellyfin.Api.Constants;using Jellyfin.Api.Controllers;+using Jellyfin.Api.ModelBinders;using Jellyfin.Server.Configuration;using Jellyfin.Server.Filters;using Jellyfin.Server.Formatters;@@ -166,6 +167,8 @@ namespace Jellyfin.Server.Extensionsopts.OutputFormatters.Add(new CssOutputFormatter());opts.OutputFormatters.Add(new XmlOutputFormatter());++ opts.ModelBinderProviders.Insert(0, new CommaDelimitedArrayModelBinderProvider());})// Clear app parts to avoid other assemblies being picked up