aboutsummaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-07 11:01:47 -0700
committerUnknwon <u@gogs.io>2016-08-07 11:01:47 -0700
commit99385db0c418fb49838eb1a23f391cf826d99202 (patch)
tree9c8fe94489becb5a1909d07156cbb8ed81f69d2f /modules/base
parent90dd0657b564210746c9c494c8c5b07dd8eee91f (diff)
downloadgitea-99385db0c418fb49838eb1a23f391cf826d99202.tar.gz
gitea-99385db0c418fb49838eb1a23f391cf826d99202.zip
#3320 code cleanup
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/tool.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index b5125cab8a..6088daf033 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -204,26 +204,23 @@ func HashEmail(email string) string {
return hex.EncodeToString(h.Sum(nil))
}
-// AvatarLink returns avatar link by given email.
+// AvatarLink returns relative avatar link to the site domain by given email,
+// which includes app sub-url as prefix. However, it is possible
+// to return full URL if user enables Gravatar-like service.
func AvatarLink(email string) (url string) {
-
- if !setting.OfflineMode {
- if setting.EnableFederatedAvatar && setting.LibravatarService != nil {
- var err error
- url, err = setting.LibravatarService.FromEmail(email)
- if err != nil {
- log.Error(1, "LibravatarService.FromEmail:: %v", err)
- }
- }
- if len(url) == 0 && !setting.DisableGravatar {
- url = setting.GravatarSource + HashEmail(email)
+ if setting.EnableFederatedAvatar && setting.LibravatarService != nil {
+ var err error
+ url, err = setting.LibravatarService.FromEmail(email)
+ if err != nil {
+ log.Error(1, "LibravatarService.FromEmail: %v", err)
}
}
-
+ if len(url) == 0 && !setting.DisableGravatar {
+ url = setting.GravatarSource + HashEmail(email)
+ }
if len(url) == 0 {
url = setting.AppSubUrl + "/img/avatar_default.png"
}
-
return url
}