From a5e065dd31b71bdc77f6c485d37d2e3269504994 Mon Sep 17 00:00:00 2001 From: V1ck3s Date: Mon, 8 Dec 2025 22:33:21 +0100 Subject: [PATCH] fix: remove broken ping endpoint and improve error handling - Remove custom /ping endpoint that returned non-standard JSON format - Fix wildcard endpoint to return Subsonic-compatible error responses - All requests now properly relay to/from the real Subsonic server --- octo-fiesta/Controllers/SubSonicController.cs | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/octo-fiesta/Controllers/SubSonicController.cs b/octo-fiesta/Controllers/SubSonicController.cs index 9b266ae..30a8270 100644 --- a/octo-fiesta/Controllers/SubSonicController.cs +++ b/octo-fiesta/Controllers/SubSonicController.cs @@ -88,17 +88,6 @@ public class SubsonicController : ControllerBase return (body, contentType); } - [HttpGet, HttpPost] - [Route("ping")] - public async Task Ping() - { - var parameters = await ExtractAllParameters(); - var xml = await RelayToSubsonic("ping", parameters); - var doc = XDocument.Parse((string)xml.Body); - var status = doc.Root?.Attribute("status")?.Value; - return Ok(new { status }); - } - /// /// Endpoint search3 personnalisé - fusionne les résultats locaux et externes /// @@ -749,21 +738,24 @@ public class SubsonicController : ControllerBase #endregion - // Generic endpoint to handle all subsonic API calls - [HttpGet, HttpPost] - [Route("{**endpoint}")] - public async Task GenericEndpoint(string endpoint) - { - var parameters = await ExtractAllParameters(); - try - { - var result = await RelayToSubsonic(endpoint, parameters); - var contentType = result.ContentType ?? $"application/{parameters.GetValueOrDefault("f", "xml")}"; - return File((byte[])result.Body, contentType); - } - catch (HttpRequestException ex) - { - return BadRequest(new { error = $"Error while calling Subsonic: {ex.Message}" }); - } - } + // Generic endpoint to handle all subsonic API calls + [HttpGet, HttpPost] + [Route("{**endpoint}")] + public async Task GenericEndpoint(string endpoint) + { + var parameters = await ExtractAllParameters(); + var format = parameters.GetValueOrDefault("f", "xml"); + + try + { + var result = await RelayToSubsonic(endpoint, parameters); + var contentType = result.ContentType ?? $"application/{format}"; + return File((byte[])result.Body, contentType); + } + catch (HttpRequestException ex) + { + // Return Subsonic-compatible error response + return CreateSubsonicError(format, 0, $"Error connecting to Subsonic server: {ex.Message}"); + } + } } \ No newline at end of file