@@ -13,6 +13,7 @@ import (
13
13
"sync"
14
14
15
15
"code.gitea.io/gitea/models/db"
16
+ system_model "code.gitea.io/gitea/models/system"
16
17
"code.gitea.io/gitea/modules/base"
17
18
"code.gitea.io/gitea/modules/cache"
18
19
"code.gitea.io/gitea/modules/log"
@@ -72,7 +73,7 @@ func GetEmailForHash(md5Sum string) (string, error) {
72
73
// LibravatarURL returns the URL for the given email. Slow due to the DNS lookup.
73
74
// This function should only be called if a federated avatar service is enabled.
74
75
func LibravatarURL (email string ) (* url.URL , error ) {
75
- urlStr , err := setting .LibravatarService .FromEmail (email )
76
+ urlStr , err := system_model .LibravatarService .FromEmail (email )
76
77
if err != nil {
77
78
log .Error ("LibravatarService.FromEmail(email=%s): error %v" , email , err )
78
79
return nil , err
@@ -149,8 +150,10 @@ func generateEmailAvatarLink(email string, size int, final bool) string {
149
150
return DefaultAvatarLink ()
150
151
}
151
152
153
+ enableFederatedAvatar , _ := system_model .GetSetting (system_model .KeyPictureEnableFederatedAvatar )
154
+
152
155
var err error
153
- if setting . EnableFederatedAvatar && setting .LibravatarService != nil {
156
+ if enableFederatedAvatar != nil && enableFederatedAvatar . GetValueBool () && system_model .LibravatarService != nil {
154
157
emailHash := saveEmailHash (email )
155
158
if final {
156
159
// for final link, we can spend more time on slow external query
@@ -166,12 +169,16 @@ func generateEmailAvatarLink(email string, size int, final bool) string {
166
169
urlStr += "?size=" + strconv .Itoa (size )
167
170
}
168
171
return urlStr
169
- } else if ! setting .DisableGravatar {
172
+ }
173
+
174
+ disableGravatar , _ := system_model .GetSetting (system_model .KeyPictureDisableGravatar )
175
+ if disableGravatar != nil && ! disableGravatar .GetValueBool () {
170
176
// copy GravatarSourceURL, because we will modify its Path.
171
- avatarURLCopy := * setting .GravatarSourceURL
177
+ avatarURLCopy := * system_model .GravatarSourceURL
172
178
avatarURLCopy .Path = path .Join (avatarURLCopy .Path , HashEmail (email ))
173
179
return generateRecognizedAvatarURL (avatarURLCopy , size )
174
180
}
181
+
175
182
return DefaultAvatarLink ()
176
183
}
177
184
0 commit comments