aboutsummaryrefslogtreecommitdiffstats
path: root/routers/user/avatar.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/user/avatar.go')
-rw-r--r--routers/user/avatar.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/routers/user/avatar.go b/routers/user/avatar.go
index c3ece49089..4287589d1a 100644
--- a/routers/user/avatar.go
+++ b/routers/user/avatar.go
@@ -7,12 +7,14 @@ package user
import (
"errors"
"net/url"
+ "path"
"strconv"
"strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
)
// Avatar redirect browser to user avatar of requested size
@@ -70,8 +72,21 @@ func AvatarByEmailHash(ctx *context.Context) {
}
var avatarURL *url.URL
- avatarURL, err = models.LibravatarURL(email)
- if err != nil {
+
+ if setting.EnableFederatedAvatar && setting.LibravatarService != nil {
+ avatarURL, err = models.LibravatarURL(email)
+ if err != nil {
+ avatarURL, err = url.Parse(models.DefaultAvatarLink())
+ if err != nil {
+ ctx.ServerError("invalid default avatar url", err)
+ return
+ }
+ }
+ } else if !setting.DisableGravatar {
+ copyOfGravatarSourceURL := *setting.GravatarSourceURL
+ avatarURL = &copyOfGravatarSourceURL
+ avatarURL.Path = path.Join(avatarURL.Path, hash)
+ } else {
avatarURL, err = url.Parse(models.DefaultAvatarLink())
if err != nil {
ctx.ServerError("invalid default avatar url", err)