mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-08 10:27:08 +02:00
fix(subsonic): keep placeholder for unknown username when Gravatar is off
The old getAvatar never looked up the user when Gravatar was disabled (the default), so an unknown username served the placeholder. Restore that for the unresolvable-user case now that lookup always happens.
This commit is contained in:
parent
1421604d6a
commit
e7f3245acd
2 changed files with 17 additions and 1 deletions
|
|
@ -28,6 +28,11 @@ func (api *Router) GetAvatar(w http.ResponseWriter, r *http.Request) (*responses
|
|||
ctx := r.Context()
|
||||
u, err := api.ds.User(ctx).FindByUsername(username)
|
||||
if err != nil {
|
||||
// Preserve the pre-upload-avatar behaviour: an unresolvable user must not surface
|
||||
// as an error when Gravatar is off, since the old handler never looked it up.
|
||||
if !conf.Server.EnableGravatar {
|
||||
return api.getPlaceHolderAvatar(w, r)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
// An uploaded avatar wins regardless of Gravatar settings, so it must be checked first.
|
||||
|
|
|
|||
|
|
@ -246,11 +246,22 @@ var _ = Describe("MediaRetrievalController", func() {
|
|||
Expect(w.Code).To(Equal(http.StatusOK))
|
||||
})
|
||||
|
||||
It("returns the same error as before for an unknown username", func() {
|
||||
It("returns the same error as before for an unknown username when Gravatar is on", func() {
|
||||
conf.Server.EnableGravatar = true
|
||||
|
||||
_, err := router.GetAvatar(w, newGetRequest("username=ghost"))
|
||||
|
||||
Expect(err).To(MatchError(model.ErrNotFound))
|
||||
})
|
||||
|
||||
It("serves the placeholder for an unknown username when Gravatar is off, as before", func() {
|
||||
conf.Server.EnableGravatar = false
|
||||
|
||||
_, err := router.GetAvatar(w, newGetRequest("username=ghost"))
|
||||
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(w.Code).To(Equal(http.StatusOK))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("GetLyrics", func() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue