aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting/picture.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/setting/picture.go')
-rw-r--r--modules/setting/picture.go60
1 files changed, 21 insertions, 39 deletions
diff --git a/modules/setting/picture.go b/modules/setting/picture.go
index a6d3447dcc..af9041ade3 100644
--- a/modules/setting/picture.go
+++ b/modules/setting/picture.go
@@ -4,14 +4,6 @@
package setting
-import (
- "net/url"
-
- "code.gitea.io/gitea/modules/log"
-
- "strk.kbt.io/projects/go/libravatar"
-)
-
// settings
var (
// Picture settings
@@ -30,10 +22,8 @@ var (
}
GravatarSource string
- GravatarSourceURL *url.URL
- DisableGravatar bool
- EnableFederatedAvatar bool
- LibravatarService *libravatar.Libravatar
+ DisableGravatar bool // Depreciated: migrated to database
+ EnableFederatedAvatar bool // Depreciated: migrated to database
RepoAvatar = struct {
Storage
@@ -69,38 +59,30 @@ func newPictureService() {
default:
GravatarSource = source
}
- DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
- EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool(!InstallLock)
- if OfflineMode {
- DisableGravatar = true
- EnableFederatedAvatar = false
- }
- if DisableGravatar {
- EnableFederatedAvatar = false
- }
- if EnableFederatedAvatar || !DisableGravatar {
- var err error
- GravatarSourceURL, err = url.Parse(GravatarSource)
- if err != nil {
- log.Fatal("Failed to parse Gravatar URL(%s): %v",
- GravatarSource, err)
- }
- }
- if EnableFederatedAvatar {
- LibravatarService = libravatar.New()
- if GravatarSourceURL.Scheme == "https" {
- LibravatarService.SetUseHTTPS(true)
- LibravatarService.SetSecureFallbackHost(GravatarSourceURL.Host)
- } else {
- LibravatarService.SetUseHTTPS(false)
- LibravatarService.SetFallbackHost(GravatarSourceURL.Host)
- }
- }
+ DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool(GetDefaultDisableGravatar())
+ deprecatedSettingDB("", "DISABLE_GRAVATAR")
+ EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool(GetDefaultEnableFederatedAvatar(DisableGravatar))
+ deprecatedSettingDB("", "ENABLE_FEDERATED_AVATAR")
newRepoAvatarService()
}
+func GetDefaultDisableGravatar() bool {
+ return !OfflineMode
+}
+
+func GetDefaultEnableFederatedAvatar(disableGravatar bool) bool {
+ v := !InstallLock
+ if OfflineMode {
+ v = false
+ }
+ if disableGravatar {
+ v = false
+ }
+ return v
+}
+
func newRepoAvatarService() {
sec := Cfg.Section("picture")