From 21c91b7dff29107eeadfeec9ed6305fd43fa49b4 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Tue, 17 Jan 2023 23:00:19 +0800 Subject: Set disable_gravatar/enable_federated_avatar when offline mode is true (#22479) When offline mode is true, we should set `disable_gravatar` to `true` and `enable_federated_avatar` to `false` in system settings. --- models/system/setting.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'models/system') diff --git a/models/system/setting.go b/models/system/setting.go index 0701c4bf48..50fe17498e 100644 --- a/models/system/setting.go +++ b/models/system/setting.go @@ -268,6 +268,16 @@ func Init() error { if setting_module.OfflineMode { disableGravatar = true enableFederatedAvatar = false + if !GetSettingBool(KeyPictureDisableGravatar) { + if err := SetSettingNoVersion(KeyPictureDisableGravatar, "true"); err != nil { + return fmt.Errorf("Failed to set setting %q: %w", KeyPictureDisableGravatar, err) + } + } + if GetSettingBool(KeyPictureEnableFederatedAvatar) { + if err := SetSettingNoVersion(KeyPictureEnableFederatedAvatar, "false"); err != nil { + return fmt.Errorf("Failed to set setting %q: %w", KeyPictureEnableFederatedAvatar, err) + } + } } if enableFederatedAvatar || !disableGravatar { -- cgit v1.2.3