mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-31 15:37:51 +01:00
fix(subsonic): keep the placeholder for a missing username when Gravatar is off
Parsing username before the EnableGravatar short-circuit turned a request with no username into Subsonic error 10, where it used to return a 200 placeholder without touching the DB.
This commit is contained in:
parent
755ae5106f
commit
41d7d1d48b
2 changed files with 23 additions and 0 deletions
|
|
@ -23,6 +23,11 @@ func (api *Router) GetAvatar(w http.ResponseWriter, r *http.Request) (*responses
|
|||
p := req.Params(r)
|
||||
username, err := p.String("username")
|
||||
if err != nil {
|
||||
// Same reason as the unresolvable-user case below: the old handler short-circuited on
|
||||
// EnableGravatar before it ever looked at the parameter.
|
||||
if !conf.Server.EnableGravatar {
|
||||
return api.getPlaceHolderAvatar(w, r)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
ctx := r.Context()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
"github.com/navidrome/navidrome/tests"
|
||||
"github.com/navidrome/navidrome/utils/req"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
|
@ -262,6 +263,23 @@ var _ = Describe("MediaRetrievalController", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(w.Code).To(Equal(http.StatusOK))
|
||||
})
|
||||
|
||||
It("serves the placeholder when the username is missing and Gravatar is off, as before", func() {
|
||||
conf.Server.EnableGravatar = false
|
||||
|
||||
_, err := router.GetAvatar(w, newGetRequest())
|
||||
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(w.Code).To(Equal(http.StatusOK))
|
||||
})
|
||||
|
||||
It("returns the same error as before for a missing username when Gravatar is on", func() {
|
||||
conf.Server.EnableGravatar = true
|
||||
|
||||
_, err := router.GetAvatar(w, newGetRequest())
|
||||
|
||||
Expect(err).To(MatchError(req.ErrMissingParam))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("GetLyrics", func() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue