diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2022-06-10 21:59:21 -0400 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2022-06-10 23:43:18 -0400 |
| commit | 0e1a41f7e938e415c32364ff1a4c97b8abab5fae (patch) | |
| tree | a86393f12fbfd177d66dfb8c131592e0ca55935c /Jellyfin.Api/Attributes | |
| parent | 5ddf4e031c48d1df59c3fceb28f1faf965ab6868 (diff) | |
Merge pull request #7868 from cvium/disable_dlna
(cherry picked from commit aa0f6cb5eb7c7750cc750412fdfcb266b0a5409e)
Signed-off-by: crobibero <cody@robibe.ro>
Diffstat (limited to 'Jellyfin.Api/Attributes')
| -rw-r--r-- | Jellyfin.Api/Attributes/DlnaEnabledAttribute.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Jellyfin.Api/Attributes/DlnaEnabledAttribute.cs b/Jellyfin.Api/Attributes/DlnaEnabledAttribute.cs new file mode 100644 index 000000000..d3a6ac9c8 --- /dev/null +++ b/Jellyfin.Api/Attributes/DlnaEnabledAttribute.cs @@ -0,0 +1,25 @@ +using Emby.Dlna; +using MediaBrowser.Controller.Configuration; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.DependencyInjection; + +namespace Jellyfin.Api.Attributes; + +/// <inheritdoc /> +public sealed class DlnaEnabledAttribute : ActionFilterAttribute +{ + /// <inheritdoc /> + public override void OnActionExecuting(ActionExecutingContext context) + { + var serverConfigurationManager = context.HttpContext.RequestServices.GetRequiredService<IServerConfigurationManager>(); + + var enabled = serverConfigurationManager.GetDlnaConfiguration().EnableServer; + + if (!enabled) + { + context.Result = new StatusCodeResult(StatusCodes.Status503ServiceUnavailable); + } + } +} |
