diff --git a/pkg/routes/api/v1/avatar.go b/pkg/routes/api/v1/avatar.go index 488eb0e9..03c9e057 100644 --- a/pkg/routes/api/v1/avatar.go +++ b/pkg/routes/api/v1/avatar.go @@ -62,14 +62,13 @@ func GetAvatar(c echo.Context) error { // Get the user u, err := user.GetUserWithEmail(s, &user.User{Username: username}) - if err != nil { + if err != nil && !user.IsErrUserDoesNotExist(err) { log.Errorf("Error getting user for avatar: %v", err) return handler.HandleHTTPError(err, c) } - // Initialize the avatar provider - // For now, we only have one avatar provider, in the future there could be multiple which - // could be changed based on user settings etc. + found := !(err != nil && user.IsErrUserDoesNotExist(err)) + var avatarProvider avatar.Provider switch u.AvatarProvider { case "gravatar": @@ -82,6 +81,10 @@ func GetAvatar(c echo.Context) error { avatarProvider = &empty.Provider{} } + if !found { + avatarProvider = &empty.Provider{} + } + size := c.QueryParam("size") var sizeInt int64 = 250 // Default size of 250 if size != "" {