Show empty avatar when the user was not found

This commit is contained in:
kolaente 2021-04-07 14:56:44 +02:00
parent 325dcc5795
commit cb0df3ebbc
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B

View File

@ -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 != "" {