Revert "config/diff: add utility function to get diffs scoped with struct tags (#20297)" (#20391)

This reverts commit a18934b042.
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-06-08 17:28:35 +03:00
коммит произвёл GitHub
родитель ef3f1b5796
Коммит c986693e4a
4 изменённых файлов: 22 добавлений и 169 удалений

Просмотреть файл

@@ -161,13 +161,10 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) {
// There are some settings that cannot be changed in a cloud env
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
diffs, diffErr := config.DiffTags(appCfg, cfg, "access", "cloud_restrictable")
if diffErr != nil {
c.Err = model.NewAppError("updateConfig", "api.config.update_config.diff.app_error", nil, diffErr.Error(), http.StatusInternalServerError)
return
}
if len(diffs) > 0 {
c.Err = model.NewAppError("updateConfig", "api.config.update_config.not_allowed_security.app_error", map[string]interface{}{"Name": diffs[0].Path}, "", http.StatusForbidden)
// Both of them cannot be nil since cfg.SetDefaults is called earlier for cfg,
// and appCfg is the existing earlier config and if it's nil, server sets a default value.
if *appCfg.ComplianceSettings.Directory != *cfg.ComplianceSettings.Directory {
c.Err = model.NewAppError("updateConfig", "api.config.update_config.not_allowed_security.app_error", map[string]interface{}{"Name": "ComplianceSettings.Directory"}, "", http.StatusForbidden)
return
}
}
@@ -302,6 +299,14 @@ func patchConfig(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
// There are some settings that cannot be changed in a cloud env
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
if cfg.ComplianceSettings.Directory != nil && *appCfg.ComplianceSettings.Directory != *cfg.ComplianceSettings.Directory {
c.Err = model.NewAppError("patchConfig", "api.config.update_config.not_allowed_security.app_error", map[string]interface{}{"Name": "ComplianceSettings.Directory"}, "", http.StatusForbidden)
return
}
}
if cfg.MessageExportSettings.EnableExport != nil {
c.App.HandleMessageExportConfig(cfg, appCfg)
}
@@ -315,19 +320,6 @@ func patchConfig(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
// There are some settings that cannot be changed in a cloud env
if c.App.Channels().License() != nil && *c.App.Channels().License().Features.Cloud {
diffs, diffErr := config.DiffTags(appCfg, updatedCfg, "access", "cloud_restrictable")
if diffErr != nil {
c.Err = model.NewAppError("patchConfig", "api.config.update_config.diff.app_error", nil, diffErr.Error(), http.StatusInternalServerError)
return
}
if len(diffs) > 0 {
c.Err = model.NewAppError("patchConfig", "api.config.update_config.not_allowed_security.app_error", map[string]interface{}{"Name": diffs[0].Path}, "", http.StatusForbidden)
return
}
}
err := updatedCfg.IsValid()
if err != nil {
c.Err = err