diff --git a/.goreleaser.yml b/.goreleaser.yml index 856a73be..dc7f0c5e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -19,7 +19,7 @@ builds: flags: - -tags=embed ldflags: - - -X main.gitSha={{.ShortCommit}} -X main.gitTag={{.Tag}} + - -X github.com/deluan/navidrome/consts.gitSha={{.ShortCommit}} -X github.com/deluan/navidrome/consts.gitTag={{.Tag}} - id: navidrome_linux env: @@ -32,7 +32,7 @@ builds: - -tags=embed ldflags: - "-extldflags '-static'" - - -X main.gitSha={{.ShortCommit}} -X main.gitTag={{.Tag}} + - -X github.com/deluan/navidrome/consts.gitSha={{.ShortCommit}} -X github.com/deluan/navidrome/consts.gitTag={{.Tag}} - id: navidrome_windows_i686 env: @@ -47,7 +47,7 @@ builds: - -tags=embed ldflags: - "-extldflags '-static'" - - -X main.gitSha={{.ShortCommit}} -X main.gitTag={{.Tag}} + - -X github.com/deluan/navidrome/consts.gitSha={{.ShortCommit}} -X github.com/deluan/navidrome/consts.gitTag={{.Tag}} - id: navidrome_windows_x64 env: @@ -62,7 +62,7 @@ builds: - -tags=embed ldflags: - "-extldflags '-static'" - - -X main.gitSha={{.ShortCommit}} -X main.gitTag={{.Tag}} + - -X github.com/deluan/navidrome/consts.gitSha={{.ShortCommit}} -X github.com/deluan/navidrome/consts.gitTag={{.Tag}} archives: - diff --git a/Dockerfile b/Dockerfile index e09eaa3e..7043c716 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,7 @@ RUN GIT_TAG=$(git name-rev --name-only HEAD) && \ GIT_SHA=$(git rev-parse --short HEAD) && \ echo "Building version: ${GIT_TAG} (${GIT_SHA})" && \ go-bindata -fs -prefix ui/build -tags embed -nocompress -pkg assets -o assets/embedded_gen.go ui/build/... && \ - go build -ldflags="-X main.gitSha=${GIT_SHA} -X main.gitTag=${GIT_TAG}" -tags=embed + go build -ldflags="-X github.com/deluan/navidrome/consts.gitSha=${GIT_SHA} -X github.com/deluan/navidrome/consts.gitTag=${GIT_TAG}" -tags=embed ##################################################### ### Build Final Image diff --git a/Makefile b/Makefile index e0bbef9a..d93ee47a 100644 --- a/Makefile +++ b/Makefile @@ -69,8 +69,8 @@ assets/embedded_gen.go: ui/build .PHONY: build build: check_go_env - go build -ldflags="-X main.gitSha=$(GIT_SHA) -X main.gitTag=master" + go build -ldflags="-X github.com/deluan/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/deluan/navidrome/consts.gitTag=master" .PHONY: buildall buildall: check_go_env assets/embedded_gen.go - go build -ldflags="-X main.gitSha=$(GIT_SHA) -X main.gitTag=master" -tags=embed + go build -ldflags="-X github.com/deluan/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/deluan/navidrome/consts.gitTag=master" -tags=embed diff --git a/banner.go b/banner.go index abef60dd..e32b8091 100644 --- a/banner.go +++ b/banner.go @@ -4,33 +4,17 @@ import ( "fmt" "strings" + "github.com/deluan/navidrome/consts" "github.com/deluan/navidrome/static" ) -var ( - // This will be set in build time. If not, version will be set to "dev" - gitTag string - gitSha string -) - -// Formats: -// dev -// v0.2.0 (5b84188) -// master (9ed35cb) -func getVersion() string { - if gitSha == "" { - return "dev" - } - return fmt.Sprintf("%s (%s)", gitTag, gitSha) -} - func getBanner() string { data, _ := static.Asset("banner.txt") return strings.TrimSuffix(string(data), "\n") } func ShowBanner() { - version := "Version: " + getVersion() + version := "Version: " + consts.Version() padding := strings.Repeat(" ", 52-len(version)) fmt.Printf("%s%s%s\n\n", getBanner(), padding, version) } diff --git a/conf/configuration.go b/conf/configuration.go index 2118de73..9652d13f 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -52,8 +52,6 @@ func newWithPath(path string, skipFlags ...bool) *multiconfig.DefaultLoader { if strings.HasSuffix(path, "yml") || strings.HasSuffix(path, "yaml") { loaders = append(loaders, &multiconfig.YAMLLoader{Path: path}) } - } else { - println("Skipping config file not found: ", path) } e := &multiconfig.EnvironmentLoader{} diff --git a/consts/consts.go b/consts/consts.go index 6cf3e37f..d1ff9dbe 100644 --- a/consts/consts.go +++ b/consts/consts.go @@ -3,6 +3,8 @@ package consts import "time" const ( + AppName = "navidrome" + LocalConfigFile = "./navidrome.toml" InitialSetupFlagKey = "InitialSetup" @@ -10,7 +12,5 @@ const ( JWTIssuer = "ND" JWTTokenExpiration = 30 * time.Minute - InitialUserName = "admin" - UIAssetsLocalPath = "ui/build" ) diff --git a/consts/version.go b/consts/version.go new file mode 100644 index 00000000..38f7f799 --- /dev/null +++ b/consts/version.go @@ -0,0 +1,20 @@ +package consts + +import "fmt" + +var ( + // This will be set in build time. If not, version will be set to "dev" + gitTag string + gitSha string +) + +// Formats: +// dev +// v0.2.0 (5b84188) +// master (9ed35cb) +func Version() string { + if gitSha == "" { + return "dev" + } + return fmt.Sprintf("%s (%s)", gitTag, gitSha) +} diff --git a/engine/playlists.go b/engine/playlists.go index d05323de..5033c434 100644 --- a/engine/playlists.go +++ b/engine/playlists.go @@ -3,7 +3,6 @@ package engine import ( "context" - "github.com/deluan/navidrome/consts" "github.com/deluan/navidrome/model" "github.com/deluan/navidrome/utils" ) @@ -52,12 +51,11 @@ func (p *playlists) Create(ctx context.Context, playlistId, name string, ids []s } func (p *playlists) getUser(ctx context.Context) string { - owner := consts.InitialUserName user, ok := ctx.Value("user").(*model.User) if ok { - owner = user.UserName + return user.UserName } - return owner + return "" } func (p *playlists) Delete(ctx context.Context, playlistId string) error { diff --git a/server/app/auth.go b/server/app/auth.go index 4a9f5358..edc9ff67 100644 --- a/server/app/auth.go +++ b/server/app/auth.go @@ -109,7 +109,7 @@ func CreateAdmin(ds model.DataStore) func(w http.ResponseWriter, r *http.Request func createDefaultUser(ctx context.Context, ds model.DataStore, username, password string) error { id, _ := uuid.NewRandom() - log.Warn("Creating initial user", "user", consts.InitialUserName) + log.Warn("Creating initial user", "user", username) initialUser := model.User{ ID: id.String(), UserName: username, diff --git a/server/subsonic/api.go b/server/subsonic/api.go index b4a8e7db..a2f6a431 100644 --- a/server/subsonic/api.go +++ b/server/subsonic/api.go @@ -151,11 +151,12 @@ func HGone(r chi.Router, path string) { } func SendError(w http.ResponseWriter, r *http.Request, err error) { - response := &responses.Subsonic{Version: Version, Status: "fail"} + response := NewResponse() code := responses.ErrorGeneric if e, ok := err.(SubsonicError); ok { code = e.code } + response.Status = "fail" response.Error = &responses.Error{Code: code, Message: err.Error()} SendResponse(w, r, response) diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.go index 016d6b25..fdf87c13 100644 --- a/server/subsonic/helpers.go +++ b/server/subsonic/helpers.go @@ -7,6 +7,7 @@ import ( "strings" "time" + "github.com/deluan/navidrome/consts" "github.com/deluan/navidrome/engine" "github.com/deluan/navidrome/model" "github.com/deluan/navidrome/server/subsonic/responses" @@ -14,7 +15,7 @@ import ( ) func NewResponse() *responses.Subsonic { - return &responses.Subsonic{Status: "ok", Version: Version} + return &responses.Subsonic{Status: "ok", Version: Version, Type: consts.AppName, ServerVersion: consts.Version()} } func RequiredParamString(r *http.Request, param string, msg string) (string, error) { diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList with data should match .JSON index 50eb05c0..91795878 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList with data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList with data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","albumList":{"album":[{"id":"1","isDir":false,"title":"title"}]}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","albumList":{"album":[{"id":"1","isDir":false,"title":"title"}]}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList with data should match .XML index e9a9e284..b2a84178 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList with data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList with data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList without data should match .JSON index 52933f99..497f1609 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList without data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList without data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","albumList":{}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","albumList":{}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList without data should match .XML index 66367095..b710114c 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList without data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses AlbumList without data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Child with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Child with data should match .JSON index de1b4ab5..ab135140 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Child with data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Child with data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","directory":{"child":[{"id":"1","isDir":true,"title":"title","album":"album","artist":"artist","track":1,"year":1985,"genre":"Rock","coverArt":"1","size":"8421341","contentType":"audio/flac","suffix":"flac","starred":"2016-03-02T20:30:00Z","transcodedContentType":"audio/mpeg","transcodedSuffix":"mp3","duration":146,"bitRate":320}],"id":"1","name":"N"}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","directory":{"child":[{"id":"1","isDir":true,"title":"title","album":"album","artist":"artist","track":1,"year":1985,"genre":"Rock","coverArt":"1","size":"8421341","contentType":"audio/flac","suffix":"flac","starred":"2016-03-02T20:30:00Z","transcodedContentType":"audio/mpeg","transcodedSuffix":"mp3","duration":146,"bitRate":320}],"id":"1","name":"N"}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Child with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Child with data should match .XML index 08ce917a..a2208886 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Child with data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Child with data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory with data should match .JSON index d2374a7b..f8efcb06 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory with data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory with data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","directory":{"child":[{"id":"1","isDir":false,"title":"title"}],"id":"1","name":"N"}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","directory":{"child":[{"id":"1","isDir":false,"title":"title"}],"id":"1","name":"N"}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory with data should match .XML index 37d5f05d..4ecfa040 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory with data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory with data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory without data should match .JSON index 634b2ac9..3964f66d 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory without data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory without data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","directory":{"id":"1","name":"N"}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","directory":{"id":"1","name":"N"}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory without data should match .XML index 7dc25197..8cd0bece 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory without data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Directory without data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses EmptyResponse should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses EmptyResponse should match .JSON index 88a5af61..6348cab1 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses EmptyResponse should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses EmptyResponse should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0"} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0"} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses EmptyResponse should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses EmptyResponse should match .XML index c392d4b8..bb84788d 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses EmptyResponse should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses EmptyResponse should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres with data should match .JSON index 08a4fb50..1138cfc6 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres with data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres with data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","genres":{"genre":[{"value":"Rock","songCount":1000,"albumCount":100},{"value":"Reggae","songCount":500,"albumCount":50},{"value":"Pop","songCount":0,"albumCount":0}]}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","genres":{"genre":[{"value":"Rock","songCount":1000,"albumCount":100},{"value":"Reggae","songCount":500,"albumCount":50},{"value":"Pop","songCount":0,"albumCount":0}]}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres with data should match .XML index e99952d4..038255b1 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres with data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres with data should match .XML @@ -1 +1 @@ -RockReggaePop +RockReggaePop diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres without data should match .JSON index f7f97bf4..ca90b27a 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres without data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres without data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","genres":{}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","genres":{}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres without data should match .XML index 1d0c9e4b..f0ba9ea6 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres without data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Genres without data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON index 5eac46ab..93b3a275 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","indexes":{"index":[{"name":"A","artist":[{"id":"111","name":"aaa","starred":"2016-03-02T20:30:00Z"}]}],"lastModified":"1","ignoredArticles":"A"}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","indexes":{"index":[{"name":"A","artist":[{"id":"111","name":"aaa","starred":"2016-03-02T20:30:00Z"}]}],"lastModified":"1","ignoredArticles":"A"}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .XML index f89fb21a..cf47d9e4 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .JSON index 1354beca..cb318f45 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","indexes":{"lastModified":"1","ignoredArticles":"A"}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","indexes":{"lastModified":"1","ignoredArticles":"A"}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .XML index a63f84ea..7943840d 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses License should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses License should match .JSON index 81044ba9..89e52248 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses License should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses License should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","license":{"valid":true}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","license":{"valid":true}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses License should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses License should match .XML index 4ef4e2b6..0a724f69 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses License should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses License should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .JSON index 3aec470a..0b659d36 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","musicFolders":{"musicFolder":[{"id":"111","name":"aaa"},{"id":"222","name":"bbb"}]}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","musicFolders":{"musicFolder":[{"id":"111","name":"aaa"},{"id":"222","name":"bbb"}]}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .XML index e657891c..4a4e88b5 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders without data should match .JSON index fd722392..d0a73ebd 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders without data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders without data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","musicFolders":{}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","musicFolders":{}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders without data should match .XML index a659b4cc..71a88eed 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders without data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders without data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .JSON index 851e598b..5f0a425e 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","playlists":{"playlist":[{"id":"111","name":"aaa"},{"id":"222","name":"bbb"}]}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","playlists":{"playlist":[{"id":"111","name":"aaa"},{"id":"222","name":"bbb"}]}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .XML index 6fbaf11a..df243dbb 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists without data should match .JSON index 8f34d597..3dec0b4b 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists without data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists without data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","playlists":{}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","playlists":{}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists without data should match .XML index 7a3f391d..c12651c9 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists without data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists without data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User with data should match .JSON index 79db8035..917d9c36 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User with data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User with data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","user":{"username":"deluan","email":"navidrome@deluan.com","scrobblingEnabled":false,"adminRole":false,"settingsRole":false,"downloadRole":false,"uploadRole":false,"playlistRole":false,"coverArtRole":false,"commentRole":false,"podcastRole":false,"streamRole":false,"jukeboxRole":false,"shareRole":false,"videoConversionRole":false,"folder":[1]}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","user":{"username":"deluan","email":"navidrome@deluan.com","scrobblingEnabled":false,"adminRole":false,"settingsRole":false,"downloadRole":false,"uploadRole":false,"playlistRole":false,"coverArtRole":false,"commentRole":false,"podcastRole":false,"streamRole":false,"jukeboxRole":false,"shareRole":false,"videoConversionRole":false,"folder":[1]}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User with data should match .XML index 72e5872a..ad424509 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User with data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User with data should match .XML @@ -1 +1 @@ -1 +1 diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User without data should match .JSON index f348788a..0fec700d 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User without data should match .JSON +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User without data should match .JSON @@ -1 +1 @@ -{"status":"ok","version":"1.8.0","user":{"username":"deluan","scrobblingEnabled":false,"adminRole":false,"settingsRole":false,"downloadRole":false,"uploadRole":false,"playlistRole":false,"coverArtRole":false,"commentRole":false,"podcastRole":false,"streamRole":false,"jukeboxRole":false,"shareRole":false,"videoConversionRole":false}} +{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","user":{"username":"deluan","scrobblingEnabled":false,"adminRole":false,"settingsRole":false,"downloadRole":false,"uploadRole":false,"playlistRole":false,"coverArtRole":false,"commentRole":false,"podcastRole":false,"streamRole":false,"jukeboxRole":false,"shareRole":false,"videoConversionRole":false}} diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User without data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User without data should match .XML index ec540d7c..d49c1078 100644 --- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User without data should match .XML +++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses User without data should match .XML @@ -1 +1 @@ - + diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.go index 901297ce..e77e9ed3 100644 --- a/server/subsonic/responses/responses.go +++ b/server/subsonic/responses/responses.go @@ -9,6 +9,8 @@ type Subsonic struct { XMLName xml.Name `xml:"http://subsonic.org/restapi subsonic-response" json:"-"` Status string `xml:"status,attr" json:"status"` Version string `xml:"version,attr" json:"version"` + Type string `xml:"type,attr" json:"type"` + ServerVersion string `xml:"serverVersion,attr" json:"serverVersion"` Error *Error `xml:"error,omitempty" json:"error,omitempty"` License *License `xml:"license,omitempty" json:"license,omitempty"` MusicFolders *MusicFolders `xml:"musicFolders,omitempty" json:"musicFolders,omitempty"` diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.go index c7e808bf..30ad6275 100644 --- a/server/subsonic/responses/responses_test.go +++ b/server/subsonic/responses/responses_test.go @@ -10,6 +10,7 @@ import ( "encoding/xml" "time" + "github.com/deluan/navidrome/consts" . "github.com/deluan/navidrome/server/subsonic/responses" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -18,7 +19,7 @@ import ( var _ = Describe("Responses", func() { var response *Subsonic BeforeEach(func() { - response = &Subsonic{Status: "ok", Version: "1.8.0"} + response = &Subsonic{Status: "ok", Version: "1.8.0", Type: consts.AppName, ServerVersion: "v0.0.0"} }) Describe("EmptyResponse", func() {