Show empty avatar when the user was not found
This commit is contained in:
parent
325dcc5795
commit
cb0df3ebbc
1 changed files with 7 additions and 4 deletions
|
@ -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 != "" {
|
||||
|
|
Loading…
Reference in a new issue