summaryrefslogtreecommitdiffstats
path: root/modules/base/tool.go
diff options
context:
space:
mode:
authorMatthias Loibl <mail@matthiasloibl.com>2016-11-07 21:13:38 +0100
committerMatthias Loibl <mail@matthiasloibl.com>2016-11-07 23:31:39 +0100
commitf81711f40d46208917742b871c41fe74a4b214c1 (patch)
tree84851fa966671cb19210b247baeacd01663c7795 /modules/base/tool.go
parenta5d0b4de5b5096793d980232c58774647213ffbe (diff)
downloadgitea-f81711f40d46208917742b871c41fe74a4b214c1.tar.gz
gitea-f81711f40d46208917742b871c41fe74a4b214c1.zip
Test AvatarLink and refactor with tests passing
Diffstat (limited to 'modules/base/tool.go')
-rw-r--r--modules/base/tool.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 987e651985..ff072f857f 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -202,21 +202,18 @@ func HashEmail(email string) string {
// 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) {
+func AvatarLink(email string) string {
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)
+ // TODO: This doesn't check any error. AvatarLink should return (string, error)
+ url, _ := setting.LibravatarService.FromEmail(email)
+ return url
}
- if len(url) == 0 {
- url = setting.AppSubUrl + "/img/avatar_default.png"
+
+ if !setting.DisableGravatar {
+ return setting.GravatarSource + HashEmail(email)
}
- return url
+
+ return setting.AppSubUrl + "/img/avatar_default.png"
}
// Seconds-based time units