|
|
@ -192,13 +192,21 @@ func HashEmail(email string) string { |
|
|
|
return EncodeMD5(strings.ToLower(strings.TrimSpace(email))) |
|
|
|
return EncodeMD5(strings.ToLower(strings.TrimSpace(email))) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DefaultAvatarLink the default avatar link
|
|
|
|
|
|
|
|
func DefaultAvatarLink() string { |
|
|
|
|
|
|
|
return setting.AppSubURL + "/img/avatar_default.png" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// AvatarLink returns relative avatar link to the site domain 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
|
|
|
|
// which includes app sub-url as prefix. However, it is possible
|
|
|
|
// to return full URL if user enables Gravatar-like service.
|
|
|
|
// to return full URL if user enables Gravatar-like service.
|
|
|
|
func AvatarLink(email string) string { |
|
|
|
func AvatarLink(email string) string { |
|
|
|
if setting.EnableFederatedAvatar && setting.LibravatarService != nil { |
|
|
|
if setting.EnableFederatedAvatar && setting.LibravatarService != nil { |
|
|
|
// TODO: This doesn't check any error. AvatarLink should return (string, error)
|
|
|
|
url, err := setting.LibravatarService.FromEmail(email) |
|
|
|
url, _ := setting.LibravatarService.FromEmail(email) |
|
|
|
if err != nil { |
|
|
|
|
|
|
|
log.Error(4, "LibravatarService.FromEmail(email=%s): error %v", email, err) |
|
|
|
|
|
|
|
return DefaultAvatarLink() |
|
|
|
|
|
|
|
} |
|
|
|
return url |
|
|
|
return url |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -206,7 +214,7 @@ func AvatarLink(email string) string { |
|
|
|
return setting.GravatarSource + HashEmail(email) |
|
|
|
return setting.GravatarSource + HashEmail(email) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return setting.AppSubURL + "/img/avatar_default.png" |
|
|
|
return DefaultAvatarLink() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Seconds-based time units
|
|
|
|
// Seconds-based time units
|
|
|
|