0e1a41f7e9
(cherry picked from commit aa0f6cb5eb
)
Signed-off-by: crobibero <cody@robibe.ro>
26 lines
803 B
C#
26 lines
803 B
C#
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);
|
|
}
|
|
}
|
|
}
|