From f06d52c4756fa2b61744fb11d7cf105b349a1885 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 18 Dec 2020 23:29:21 +0000 Subject: [PATCH 1/6] Disable API if dlna is disabled. --- Emby.Dlna/Main/DlnaEntryPoint.cs | 6 +++ .../Controllers/DlnaServerController.cs | 39 +++++++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs index fb4454a34..175a1ad2b 100644 --- a/Emby.Dlna/Main/DlnaEntryPoint.cs +++ b/Emby.Dlna/Main/DlnaEntryPoint.cs @@ -126,6 +126,11 @@ namespace Emby.Dlna.Main public static DlnaEntryPoint Current { get; private set; } + /// + /// Gets a value indicating whether the dlna server is enabled. + /// + public static bool Enabled { get; private set; } + public IContentDirectory ContentDirectory { get; private set; } public IConnectionManager ConnectionManager { get; private set; } @@ -152,6 +157,7 @@ namespace Emby.Dlna.Main private void ReloadComponents() { var options = _config.GetDlnaConfiguration(); + Enabled = options.EnableServer; StartSsdpHandler(); diff --git a/Jellyfin.Api/Controllers/DlnaServerController.cs b/Jellyfin.Api/Controllers/DlnaServerController.cs index 4fd9c2fbf..8555cbfa6 100644 --- a/Jellyfin.Api/Controllers/DlnaServerController.cs +++ b/Jellyfin.Api/Controllers/DlnaServerController.cs @@ -45,14 +45,20 @@ namespace Jellyfin.Api.Controllers [HttpGet("{serverId}/description")] [HttpGet("{serverId}/description.xml", Name = "GetDescriptionXml_2")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public ActionResult GetDescriptionXml([FromRoute, Required] string serverId) { - var url = GetAbsoluteUri(); - var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase)); - var xml = _dlnaManager.GetServerDescriptionXml(Request.Headers, serverId, serverAddress); - return Ok(xml); + if (DlnaEntryPoint.Enabled) + { + var url = GetAbsoluteUri(); + var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase)); + var xml = _dlnaManager.GetServerDescriptionXml(Request.Headers, serverId, serverAddress); + return Ok(xml); + } + + return NotFound(); } /// @@ -65,12 +71,18 @@ namespace Jellyfin.Api.Controllers [HttpGet("{serverId}/ContentDirectory/ContentDirectory", Name = "GetContentDirectory_2")] [HttpGet("{serverId}/ContentDirectory/ContentDirectory.xml", Name = "GetContentDirectory_3")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] public ActionResult GetContentDirectory([FromRoute, Required] string serverId) { - return Ok(_contentDirectory.GetServiceXml()); + if (DlnaEntryPoint.Enabled) + { + return Ok(_contentDirectory.GetServiceXml()); + } + + return NotFound(); } /// @@ -83,12 +95,18 @@ namespace Jellyfin.Api.Controllers [HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar", Name = "GetMediaReceiverRegistrar_2")] [HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar.xml", Name = "GetMediaReceiverRegistrar_3")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] public ActionResult GetMediaReceiverRegistrar([FromRoute, Required] string serverId) { - return Ok(_mediaReceiverRegistrar.GetServiceXml()); + if (DlnaEntryPoint.Enabled) + { + return Ok(_mediaReceiverRegistrar.GetServiceXml()); + } + + return NotFound(); } /// @@ -101,12 +119,18 @@ namespace Jellyfin.Api.Controllers [HttpGet("{serverId}/ConnectionManager/ConnectionManager", Name = "GetConnectionManager_2")] [HttpGet("{serverId}/ConnectionManager/ConnectionManager.xml", Name = "GetConnectionManager_3")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] public ActionResult GetConnectionManager([FromRoute, Required] string serverId) { - return Ok(_connectionManager.GetServiceXml()); + if (DlnaEntryPoint.Enabled) + { + return Ok(_connectionManager.GetServiceXml()); + } + + return NotFound(); } /// @@ -147,6 +171,7 @@ namespace Jellyfin.Api.Controllers /// Control response. [HttpPost("{serverId}/MediaReceiverRegistrar/Control")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public async Task> ProcessMediaReceiverRegistrarControlRequest([FromRoute, Required] string serverId) From c98144c60d25b2ccb6f6ad3e2e2b1b04f88067ab Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Fri, 18 Dec 2020 23:59:21 +0000 Subject: [PATCH 2/6] Updated docs. --- Jellyfin.Api/Controllers/DlnaServerController.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jellyfin.Api/Controllers/DlnaServerController.cs b/Jellyfin.Api/Controllers/DlnaServerController.cs index 8555cbfa6..914add9f1 100644 --- a/Jellyfin.Api/Controllers/DlnaServerController.cs +++ b/Jellyfin.Api/Controllers/DlnaServerController.cs @@ -41,6 +41,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Description xml returned. + /// Not found. /// An containing the description xml. [HttpGet("{serverId}/description")] [HttpGet("{serverId}/description.xml", Name = "GetDescriptionXml_2")] @@ -66,6 +67,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Dlna content directory returned. + /// Not found. /// An containing the dlna content directory xml. [HttpGet("{serverId}/ContentDirectory")] [HttpGet("{serverId}/ContentDirectory/ContentDirectory", Name = "GetContentDirectory_2")] @@ -90,6 +92,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Dlna media receiver registrar xml returned. + /// Not found. /// Dlna media receiver registrar xml. [HttpGet("{serverId}/MediaReceiverRegistrar")] [HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar", Name = "GetMediaReceiverRegistrar_2")] @@ -114,6 +117,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Dlna media receiver registrar xml returned. + /// Not found. /// Dlna media receiver registrar xml. [HttpGet("{serverId}/ConnectionManager")] [HttpGet("{serverId}/ConnectionManager/ConnectionManager", Name = "GetConnectionManager_2")] @@ -168,6 +172,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. + /// Not found. /// Control response. [HttpPost("{serverId}/MediaReceiverRegistrar/Control")] [ProducesResponseType(StatusCodes.Status200OK)] From 3d0b9f9ea14a4ffae2daffb454162fe05d626b14 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sat, 19 Dec 2020 09:34:04 +0000 Subject: [PATCH 3/6] Did the other API, --- .../Controllers/DlnaServerController.cs | 67 ++++++++++++++++--- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/Jellyfin.Api/Controllers/DlnaServerController.cs b/Jellyfin.Api/Controllers/DlnaServerController.cs index 914add9f1..42658bb8c 100644 --- a/Jellyfin.Api/Controllers/DlnaServerController.cs +++ b/Jellyfin.Api/Controllers/DlnaServerController.cs @@ -145,11 +145,17 @@ namespace Jellyfin.Api.Controllers /// Control response. [HttpPost("{serverId}/ContentDirectory/Control")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public async Task> ProcessContentDirectoryControlRequest([FromRoute, Required] string serverId) { - return await ProcessControlRequestInternalAsync(serverId, Request.Body, _contentDirectory).ConfigureAwait(false); + if (DlnaEntryPoint.Enabled) + { + return await ProcessControlRequestInternalAsync(serverId, Request.Body, _contentDirectory).ConfigureAwait(false); + } + + return NotFound(); } /// @@ -160,11 +166,17 @@ namespace Jellyfin.Api.Controllers /// Control response. [HttpPost("{serverId}/ConnectionManager/Control")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public async Task> ProcessConnectionManagerControlRequest([FromRoute, Required] string serverId) { - return await ProcessControlRequestInternalAsync(serverId, Request.Body, _connectionManager).ConfigureAwait(false); + if (DlnaEntryPoint.Enabled) + { + return await ProcessControlRequestInternalAsync(serverId, Request.Body, _connectionManager).ConfigureAwait(false); + } + + return NotFound(); } /// @@ -181,7 +193,12 @@ namespace Jellyfin.Api.Controllers [ProducesFile(MediaTypeNames.Text.Xml)] public async Task> ProcessMediaReceiverRegistrarControlRequest([FromRoute, Required] string serverId) { - return await ProcessControlRequestInternalAsync(serverId, Request.Body, _mediaReceiverRegistrar).ConfigureAwait(false); + if (DlnaEntryPoint.Enabled) + { + return await ProcessControlRequestInternalAsync(serverId, Request.Body, _mediaReceiverRegistrar).ConfigureAwait(false); + } + + return NotFound(); } /// @@ -195,11 +212,17 @@ namespace Jellyfin.Api.Controllers [ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public ActionResult ProcessMediaReceiverRegistrarEventRequest(string serverId) { - return ProcessEventRequest(_mediaReceiverRegistrar); + if (DlnaEntryPoint.Enabled) + { + return ProcessEventRequest(_mediaReceiverRegistrar); + } + + return NotFound(); } /// @@ -207,17 +230,24 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. + /// Not found. /// Event subscription response. [HttpSubscribe("{serverId}/ContentDirectory/Events")] [HttpUnsubscribe("{serverId}/ContentDirectory/Events")] [ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public ActionResult ProcessContentDirectoryEventRequest(string serverId) { - return ProcessEventRequest(_contentDirectory); + if (DlnaEntryPoint.Enabled) + { + return ProcessEventRequest(_contentDirectory); + } + + return NotFound(); } /// @@ -225,17 +255,24 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. + /// Not found. /// Event subscription response. [HttpSubscribe("{serverId}/ConnectionManager/Events")] [HttpUnsubscribe("{serverId}/ConnectionManager/Events")] [ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public ActionResult ProcessConnectionManagerEventRequest(string serverId) { - return ProcessEventRequest(_connectionManager); + if (DlnaEntryPoint.Enabled) + { + return ProcessEventRequest(_connectionManager); + } + + return NotFound(); } /// @@ -243,14 +280,21 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// The icon filename. + /// Not found. /// Icon stream. [HttpGet("{serverId}/icons/{fileName}")] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesImageFile] public ActionResult GetIconId([FromRoute, Required] string serverId, [FromRoute, Required] string fileName) { - return GetIconInternal(fileName); + if (DlnaEntryPoint.Enabled) + { + return GetIconInternal(fileName); + } + + return NotFound(); } /// @@ -258,11 +302,18 @@ namespace Jellyfin.Api.Controllers /// /// The icon filename. /// Icon stream. + /// Not found. [HttpGet("icons/{fileName}")] + [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesImageFile] public ActionResult GetIcon([FromRoute, Required] string fileName) { - return GetIconInternal(fileName); + if (DlnaEntryPoint.Enabled) + { + return GetIconInternal(fileName); + } + + return NotFound(); } private ActionResult GetIconInternal(string fileName) From 94707121186f1b71c21a0977bef7c8ab746932df Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sat, 19 Dec 2020 17:38:46 +0000 Subject: [PATCH 4/6] Added xml docs --- Jellyfin.Api/Controllers/DlnaServerController.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jellyfin.Api/Controllers/DlnaServerController.cs b/Jellyfin.Api/Controllers/DlnaServerController.cs index 42658bb8c..a3c82ed84 100644 --- a/Jellyfin.Api/Controllers/DlnaServerController.cs +++ b/Jellyfin.Api/Controllers/DlnaServerController.cs @@ -142,6 +142,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. + /// Not found. /// Control response. [HttpPost("{serverId}/ContentDirectory/Control")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -163,6 +164,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. + /// Not found. /// Control response. [HttpPost("{serverId}/ConnectionManager/Control")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -206,6 +208,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. + /// Not found. /// Event subscription response. [HttpSubscribe("{serverId}/MediaReceiverRegistrar/Events")] [HttpUnsubscribe("{serverId}/MediaReceiverRegistrar/Events")] From bf24929d271406bb6ae50eb4aaa784fdf9511b94 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Tue, 22 Dec 2020 15:23:55 +0000 Subject: [PATCH 5/6] Changed to 503. --- .../Controllers/DlnaServerController.cs | 75 ++++++++++--------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/Jellyfin.Api/Controllers/DlnaServerController.cs b/Jellyfin.Api/Controllers/DlnaServerController.cs index a3c82ed84..df7504b77 100644 --- a/Jellyfin.Api/Controllers/DlnaServerController.cs +++ b/Jellyfin.Api/Controllers/DlnaServerController.cs @@ -41,12 +41,12 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Description xml returned. - /// Not found. + /// Service Unavailable. /// An containing the description xml. [HttpGet("{serverId}/description")] [HttpGet("{serverId}/description.xml", Name = "GetDescriptionXml_2")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public ActionResult GetDescriptionXml([FromRoute, Required] string serverId) @@ -59,7 +59,7 @@ namespace Jellyfin.Api.Controllers return Ok(xml); } - return NotFound(); + return StatusCode(503); } /// @@ -67,13 +67,13 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Dlna content directory returned. - /// Not found. + /// Service Unavailable. /// An containing the dlna content directory xml. [HttpGet("{serverId}/ContentDirectory")] [HttpGet("{serverId}/ContentDirectory/ContentDirectory", Name = "GetContentDirectory_2")] [HttpGet("{serverId}/ContentDirectory/ContentDirectory.xml", Name = "GetContentDirectory_3")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] @@ -84,7 +84,7 @@ namespace Jellyfin.Api.Controllers return Ok(_contentDirectory.GetServiceXml()); } - return NotFound(); + return StatusCode(503); } /// @@ -92,13 +92,13 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Dlna media receiver registrar xml returned. - /// Not found. + /// Service Unavailable. /// Dlna media receiver registrar xml. [HttpGet("{serverId}/MediaReceiverRegistrar")] [HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar", Name = "GetMediaReceiverRegistrar_2")] [HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar.xml", Name = "GetMediaReceiverRegistrar_3")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] @@ -109,7 +109,7 @@ namespace Jellyfin.Api.Controllers return Ok(_mediaReceiverRegistrar.GetServiceXml()); } - return NotFound(); + return StatusCode(503); } /// @@ -117,13 +117,13 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Dlna media receiver registrar xml returned. - /// Not found. + /// Service Unavailable. /// Dlna media receiver registrar xml. [HttpGet("{serverId}/ConnectionManager")] [HttpGet("{serverId}/ConnectionManager/ConnectionManager", Name = "GetConnectionManager_2")] [HttpGet("{serverId}/ConnectionManager/ConnectionManager.xml", Name = "GetConnectionManager_3")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] @@ -134,7 +134,7 @@ namespace Jellyfin.Api.Controllers return Ok(_connectionManager.GetServiceXml()); } - return NotFound(); + return StatusCode(503); } /// @@ -142,11 +142,11 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Not found. + /// Service Unavailable. /// Control response. [HttpPost("{serverId}/ContentDirectory/Control")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public async Task> ProcessContentDirectoryControlRequest([FromRoute, Required] string serverId) @@ -156,7 +156,7 @@ namespace Jellyfin.Api.Controllers return await ProcessControlRequestInternalAsync(serverId, Request.Body, _contentDirectory).ConfigureAwait(false); } - return NotFound(); + return StatusCode(503); } /// @@ -164,11 +164,11 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Not found. + /// Service Unavailable. /// Control response. [HttpPost("{serverId}/ConnectionManager/Control")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public async Task> ProcessConnectionManagerControlRequest([FromRoute, Required] string serverId) @@ -178,7 +178,7 @@ namespace Jellyfin.Api.Controllers return await ProcessControlRequestInternalAsync(serverId, Request.Body, _connectionManager).ConfigureAwait(false); } - return NotFound(); + return StatusCode(503); } /// @@ -186,11 +186,11 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Not found. + /// Service Unavailable. /// Control response. [HttpPost("{serverId}/MediaReceiverRegistrar/Control")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public async Task> ProcessMediaReceiverRegistrarControlRequest([FromRoute, Required] string serverId) @@ -200,7 +200,7 @@ namespace Jellyfin.Api.Controllers return await ProcessControlRequestInternalAsync(serverId, Request.Body, _mediaReceiverRegistrar).ConfigureAwait(false); } - return NotFound(); + return StatusCode(503); } /// @@ -208,14 +208,14 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Not found. + /// Service Unavailable. /// Event subscription response. [HttpSubscribe("{serverId}/MediaReceiverRegistrar/Events")] [HttpUnsubscribe("{serverId}/MediaReceiverRegistrar/Events")] [ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public ActionResult ProcessMediaReceiverRegistrarEventRequest(string serverId) @@ -225,7 +225,7 @@ namespace Jellyfin.Api.Controllers return ProcessEventRequest(_mediaReceiverRegistrar); } - return NotFound(); + return StatusCode(503); } /// @@ -233,14 +233,14 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Not found. + /// Service Unavailable. /// Event subscription response. [HttpSubscribe("{serverId}/ContentDirectory/Events")] [HttpUnsubscribe("{serverId}/ContentDirectory/Events")] [ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public ActionResult ProcessContentDirectoryEventRequest(string serverId) @@ -250,7 +250,7 @@ namespace Jellyfin.Api.Controllers return ProcessEventRequest(_contentDirectory); } - return NotFound(); + return StatusCode(503); } /// @@ -258,14 +258,14 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Not found. + /// Service Unavailable. /// Event subscription response. [HttpSubscribe("{serverId}/ConnectionManager/Events")] [HttpUnsubscribe("{serverId}/ConnectionManager/Events")] [ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [Produces(MediaTypeNames.Text.Xml)] [ProducesFile(MediaTypeNames.Text.Xml)] public ActionResult ProcessConnectionManagerEventRequest(string serverId) @@ -275,7 +275,7 @@ namespace Jellyfin.Api.Controllers return ProcessEventRequest(_connectionManager); } - return NotFound(); + return StatusCode(503); } /// @@ -283,12 +283,15 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// The icon filename. - /// Not found. + /// Request processed. + /// Not Found. + /// Service Unavailable. /// Icon stream. [HttpGet("{serverId}/icons/{fileName}")] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [ProducesImageFile] public ActionResult GetIconId([FromRoute, Required] string serverId, [FromRoute, Required] string fileName) { @@ -297,7 +300,7 @@ namespace Jellyfin.Api.Controllers return GetIconInternal(fileName); } - return NotFound(); + return StatusCode(503); } /// @@ -305,9 +308,13 @@ namespace Jellyfin.Api.Controllers /// /// The icon filename. /// Icon stream. - /// Not found. + /// Request processed. + /// Not Found. + /// Service Unavailable. [HttpGet("icons/{fileName}")] + [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] [ProducesImageFile] public ActionResult GetIcon([FromRoute, Required] string fileName) { @@ -316,7 +323,7 @@ namespace Jellyfin.Api.Controllers return GetIconInternal(fileName); } - return NotFound(); + return StatusCode(503); } private ActionResult GetIconInternal(string fileName) From bc9462981eb7a3624d82547ea71024442c085ebd Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Tue, 22 Dec 2020 15:33:25 +0000 Subject: [PATCH 6/6] changed to constants --- .../Controllers/DlnaServerController.cs | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Jellyfin.Api/Controllers/DlnaServerController.cs b/Jellyfin.Api/Controllers/DlnaServerController.cs index df7504b77..694d16ad9 100644 --- a/Jellyfin.Api/Controllers/DlnaServerController.cs +++ b/Jellyfin.Api/Controllers/DlnaServerController.cs @@ -41,7 +41,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Description xml returned. - /// Service Unavailable. + /// DLNA is disabled. /// An containing the description xml. [HttpGet("{serverId}/description")] [HttpGet("{serverId}/description.xml", Name = "GetDescriptionXml_2")] @@ -59,7 +59,7 @@ namespace Jellyfin.Api.Controllers return Ok(xml); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -67,7 +67,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Dlna content directory returned. - /// Service Unavailable. + /// DLNA is disabled. /// An containing the dlna content directory xml. [HttpGet("{serverId}/ContentDirectory")] [HttpGet("{serverId}/ContentDirectory/ContentDirectory", Name = "GetContentDirectory_2")] @@ -84,7 +84,7 @@ namespace Jellyfin.Api.Controllers return Ok(_contentDirectory.GetServiceXml()); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -92,7 +92,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Dlna media receiver registrar xml returned. - /// Service Unavailable. + /// DLNA is disabled. /// Dlna media receiver registrar xml. [HttpGet("{serverId}/MediaReceiverRegistrar")] [HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar", Name = "GetMediaReceiverRegistrar_2")] @@ -109,7 +109,7 @@ namespace Jellyfin.Api.Controllers return Ok(_mediaReceiverRegistrar.GetServiceXml()); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -117,7 +117,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Dlna media receiver registrar xml returned. - /// Service Unavailable. + /// DLNA is disabled. /// Dlna media receiver registrar xml. [HttpGet("{serverId}/ConnectionManager")] [HttpGet("{serverId}/ConnectionManager/ConnectionManager", Name = "GetConnectionManager_2")] @@ -134,7 +134,7 @@ namespace Jellyfin.Api.Controllers return Ok(_connectionManager.GetServiceXml()); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -142,7 +142,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Service Unavailable. + /// DLNA is disabled. /// Control response. [HttpPost("{serverId}/ContentDirectory/Control")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -156,7 +156,7 @@ namespace Jellyfin.Api.Controllers return await ProcessControlRequestInternalAsync(serverId, Request.Body, _contentDirectory).ConfigureAwait(false); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -164,7 +164,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Service Unavailable. + /// DLNA is disabled. /// Control response. [HttpPost("{serverId}/ConnectionManager/Control")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -178,7 +178,7 @@ namespace Jellyfin.Api.Controllers return await ProcessControlRequestInternalAsync(serverId, Request.Body, _connectionManager).ConfigureAwait(false); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -186,7 +186,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Service Unavailable. + /// DLNA is disabled. /// Control response. [HttpPost("{serverId}/MediaReceiverRegistrar/Control")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -200,7 +200,7 @@ namespace Jellyfin.Api.Controllers return await ProcessControlRequestInternalAsync(serverId, Request.Body, _mediaReceiverRegistrar).ConfigureAwait(false); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -208,7 +208,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Service Unavailable. + /// DLNA is disabled. /// Event subscription response. [HttpSubscribe("{serverId}/MediaReceiverRegistrar/Events")] [HttpUnsubscribe("{serverId}/MediaReceiverRegistrar/Events")] @@ -225,7 +225,7 @@ namespace Jellyfin.Api.Controllers return ProcessEventRequest(_mediaReceiverRegistrar); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -233,7 +233,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Service Unavailable. + /// DLNA is disabled. /// Event subscription response. [HttpSubscribe("{serverId}/ContentDirectory/Events")] [HttpUnsubscribe("{serverId}/ContentDirectory/Events")] @@ -250,7 +250,7 @@ namespace Jellyfin.Api.Controllers return ProcessEventRequest(_contentDirectory); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -258,7 +258,7 @@ namespace Jellyfin.Api.Controllers /// /// Server UUID. /// Request processed. - /// Service Unavailable. + /// DLNA is disabled. /// Event subscription response. [HttpSubscribe("{serverId}/ConnectionManager/Events")] [HttpUnsubscribe("{serverId}/ConnectionManager/Events")] @@ -275,7 +275,7 @@ namespace Jellyfin.Api.Controllers return ProcessEventRequest(_connectionManager); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -285,7 +285,7 @@ namespace Jellyfin.Api.Controllers /// The icon filename. /// Request processed. /// Not Found. - /// Service Unavailable. + /// DLNA is disabled. /// Icon stream. [HttpGet("{serverId}/icons/{fileName}")] [SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")] @@ -300,7 +300,7 @@ namespace Jellyfin.Api.Controllers return GetIconInternal(fileName); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } /// @@ -310,7 +310,7 @@ namespace Jellyfin.Api.Controllers /// Icon stream. /// Request processed. /// Not Found. - /// Service Unavailable. + /// DLNA is disabled. [HttpGet("icons/{fileName}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] @@ -323,7 +323,7 @@ namespace Jellyfin.Api.Controllers return GetIconInternal(fileName); } - return StatusCode(503); + return StatusCode(StatusCodes.Status503ServiceUnavailable); } private ActionResult GetIconInternal(string fileName)