From 14b785d188647ae896c5d20869ab6bcc967fcfc2 Mon Sep 17 00:00:00 2001 From: KGT1 Date: Tue, 1 Apr 2025 01:46:01 +0200 Subject: Preserve SplashscreenLocation when updating branding config (#13756) * add BrandingOptionsDto and add branding endpoints * refactor new HttpGet Configuration Branding into existing API calls * Add BrandingOptions to _ignoredConfigurations for openAPI * rename BrandOptionsDto to BrandingOptionsDto --- Jellyfin.Api/Controllers/BrandingController.cs | 13 +++++++++-- .../Controllers/ConfigurationController.cs | 25 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'Jellyfin.Api') diff --git a/Jellyfin.Api/Controllers/BrandingController.cs b/Jellyfin.Api/Controllers/BrandingController.cs index 3c2c4b4db..1d948ff20 100644 --- a/Jellyfin.Api/Controllers/BrandingController.cs +++ b/Jellyfin.Api/Controllers/BrandingController.cs @@ -29,9 +29,18 @@ public class BrandingController : BaseJellyfinApiController /// An containing the branding configuration. [HttpGet("Configuration")] [ProducesResponseType(StatusCodes.Status200OK)] - public ActionResult GetBrandingOptions() + public ActionResult GetBrandingOptions() { - return _serverConfigurationManager.GetConfiguration("branding"); + var brandingOptions = _serverConfigurationManager.GetConfiguration("branding"); + + var brandingOptionsDto = new BrandingOptionsDto + { + LoginDisclaimer = brandingOptions.LoginDisclaimer, + CustomCss = brandingOptions.CustomCss, + SplashscreenEnabled = brandingOptions.SplashscreenEnabled + }; + + return brandingOptionsDto; } /// diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs index abe8bec2d..8dcaebf6d 100644 --- a/Jellyfin.Api/Controllers/ConfigurationController.cs +++ b/Jellyfin.Api/Controllers/ConfigurationController.cs @@ -9,6 +9,7 @@ using Jellyfin.Extensions.Json; using MediaBrowser.Common.Api; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.MediaEncoding; +using MediaBrowser.Model.Branding; using MediaBrowser.Model.Configuration; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; @@ -119,6 +120,30 @@ public class ConfigurationController : BaseJellyfinApiController return new MetadataOptions(); } + /// + /// Updates branding configuration. + /// + /// Branding configuration. + /// Branding configuration updated. + /// Update status. + [HttpPost("Configuration/Branding")] + [Authorize(Policy = Policies.RequiresElevation)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + public ActionResult UpdateBrandingConfiguration([FromBody, Required] BrandingOptionsDto configuration) + { + // Get the current branding configuration to preserve SplashscreenLocation + var currentBranding = (BrandingOptions)_configurationManager.GetConfiguration("branding"); + + // Update only the properties from BrandingOptionsDto + currentBranding.LoginDisclaimer = configuration.LoginDisclaimer; + currentBranding.CustomCss = configuration.CustomCss; + currentBranding.SplashscreenEnabled = configuration.SplashscreenEnabled; + + _configurationManager.SaveConfiguration("branding", currentBranding); + + return NoContent(); + } + /// /// Updates the path to the media encoder. /// -- cgit v1.2.3