diff options
Diffstat (limited to 'modules/base/tool.go')
-rw-r--r-- | modules/base/tool.go | 25 |
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 } |