MM-13185: Fix Message Export config special case. (#9898)

It should only apply when setting through the System Console, to avoid
messing up externally managed config files.
Этот коммит содержится в:
George Goldberg
2018-11-28 14:01:29 +00:00
коммит произвёл GitHub
родитель 9afb1586cd
Коммит c24c518a14
4 изменённых файлов: 88 добавлений и 11 удалений

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

@@ -130,6 +130,20 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) {
// Do not allow plugin uploads to be toggled through the API
cfg.PluginSettings.EnableUploads = c.App.GetConfig().PluginSettings.EnableUploads
// If the Message Export feature has been toggled in the System Console, rewrite the ExportFromTimestamp field to an
// appropriate value. The rewriting occurs here to ensure it doesn't affect values written to the config file
// directly and not through the System Console UI.
if *cfg.MessageExportSettings.EnableExport != *c.App.GetConfig().MessageExportSettings.EnableExport {
if *cfg.MessageExportSettings.EnableExport && *cfg.MessageExportSettings.ExportFromTimestamp == int64(0) {
// When the feature is toggled on, use the current timestamp as the start time for future exports.
cfg.MessageExportSettings.ExportFromTimestamp = model.NewInt64(model.GetMillis())
} else if !*cfg.MessageExportSettings.EnableExport {
// When the feature is disabled, reset the timestamp so that the timestamp will be set if
// the feature is re-enabled from the System Console in future.
cfg.MessageExportSettings.ExportFromTimestamp = model.NewInt64(0)
}
}
err := c.App.SaveConfig(cfg, true)
if err != nil {
c.Err = err