From d8f584dcc9630318ef584e00fdbe3afac26f4593 Mon Sep 17 00:00:00 2001 From: benya Date: Fri, 3 Apr 2026 21:19:32 +0300 Subject: [PATCH] fix: correct opensubsonic extensions response --- internal/httpapi/router.go | 4 +++- internal/subsonic/service.go | 16 +++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/internal/httpapi/router.go b/internal/httpapi/router.go index 1c822a9..617edcb 100644 --- a/internal/httpapi/router.go +++ b/internal/httpapi/router.go @@ -92,6 +92,9 @@ func NewRouter(cfg config.Config, database *sql.DB, scanService *scanner.Service restGet(rest, "getLicense", func(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, subsonic.PingResponse()) }) + restGet(rest, "getOpenSubsonicExtensions", func(w http.ResponseWriter, r *http.Request) { + writeJSON(w, http.StatusOK, subsonic.OpenSubsonicExtensionsResponse()) + }) rest.Group(func(authed chi.Router) { authed.Use(application.requireSubsonicAuth) restGet(authed, "getArtists", application.subsonicArtists) @@ -103,7 +106,6 @@ func NewRouter(cfg config.Config, database *sql.DB, scanService *scanner.Service restGet(authed, "getSongsByGenre", application.subsonicSongsByGenre) restGet(authed, "getMusicFolders", application.subsonicMusicFolders) restGet(authed, "getGenres", application.subsonicGenres) - restGet(authed, "getOpenSubsonicExtensions", application.subsonicOpenSubsonicExtensions) restGet(authed, "getPodcasts", application.subsonicPodcasts) restGet(authed, "getNewestPodcasts", application.subsonicNewestPodcasts) restGet(authed, "getInternetRadioStations", application.subsonicInternetRadioStations) diff --git a/internal/subsonic/service.go b/internal/subsonic/service.go index 538ced8..11b0388 100644 --- a/internal/subsonic/service.go +++ b/internal/subsonic/service.go @@ -37,7 +37,7 @@ type Response struct { Podcasts *Podcasts `json:"podcasts,omitempty"` NewestPods *NewestPods `json:"newestPodcasts,omitempty"` RadioStations *RadioStations `json:"internetRadioStations,omitempty"` - Extensions *Extensions `json:"openSubsonicExtensions,omitempty"` + Extensions []Extension `json:"openSubsonicExtensions,omitempty"` ScanStatus *ScanStatus `json:"scanStatus,omitempty"` Error *ErrorRef `json:"error,omitempty"` } @@ -195,13 +195,9 @@ type RadioStations struct { InternetRadioStation []any `json:"internetRadioStation,omitempty"` } -type Extensions struct { - Extension []Extension `json:"extension,omitempty"` -} - type Extension struct { Name string `json:"name"` - Versions string `json:"versions"` + Versions []int `json:"versions"` } type ErrorRef struct { @@ -546,11 +542,9 @@ func InternetRadioStationsResponse() Envelope { func OpenSubsonicExtensionsResponse() Envelope { response := PingResponse() - response.SubsonicResponse.Extensions = &Extensions{ - Extension: []Extension{ - {Name: "formPost", Versions: "1"}, - {Name: "apiKeyAuthentication", Versions: "1"}, - }, + response.SubsonicResponse.Extensions = []Extension{ + {Name: "formPost", Versions: []int{1}}, + {Name: "apiKeyAuthentication", Versions: []int{1}}, } return response }