(c *Context, w http.ResponseWriter, r *http.Request)
| 50 | } |
| 51 | |
| 52 | func localUpdateConfig(c *Context, w http.ResponseWriter, r *http.Request) { |
| 53 | var cfg *model.Config |
| 54 | err := json.NewDecoder(r.Body).Decode(&cfg) |
| 55 | if err != nil || cfg == nil { |
| 56 | c.SetInvalidParamWithErr("config", err) |
| 57 | return |
| 58 | } |
| 59 | |
| 60 | auditRec := c.MakeAuditRecord(model.AuditEventLocalUpdateConfig, model.AuditStatusFail) |
| 61 | defer c.LogAuditRec(auditRec) |
| 62 | |
| 63 | cfg.SetDefaults() |
| 64 | |
| 65 | appCfg := c.App.Config() |
| 66 | |
| 67 | c.App.HandleMessageExportConfig(cfg, appCfg) |
| 68 | |
| 69 | appErr := cfg.IsValid() |
| 70 | if appErr != nil { |
| 71 | c.Err = appErr |
| 72 | return |
| 73 | } |
| 74 | |
| 75 | oldCfg, newCfg, appErr := c.App.SaveConfig(cfg, true) |
| 76 | if appErr != nil { |
| 77 | c.Err = appErr |
| 78 | return |
| 79 | } |
| 80 | |
| 81 | diffs, diffErr := config.Diff(oldCfg, newCfg) |
| 82 | if diffErr != nil { |
| 83 | c.Err = model.NewAppError("updateConfig", "api.config.update_config.diff.app_error", nil, "", http.StatusInternalServerError).Wrap(diffErr) |
| 84 | return |
| 85 | } |
| 86 | auditRec.AddEventPriorState(&diffs) |
| 87 | |
| 88 | c.App.SanitizedConfig(newCfg) |
| 89 | |
| 90 | auditRec.Success() |
| 91 | c.LogAudit("updateConfig") |
| 92 | |
| 93 | w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") |
| 94 | if err := json.NewEncoder(w).Encode(newCfg); err != nil { |
| 95 | c.Logger.Warn("Error while writing response", mlog.Err(err)) |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | func localPatchConfig(c *Context, w http.ResponseWriter, r *http.Request) { |
| 100 | var cfg *model.Config |
nothing calls this directly
no test coverage detected
searching dependent graphs…