MM-42813: Fallback to default config if nil is passed (#19920)

https://mattermost.atlassian.net/browse/MM-42813

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Agniva De Sarker
2022-04-06 08:30:16 +05:30
committed by GitHub
parent bc69069a83
commit ec91ca46ff

View File

@@ -196,11 +196,9 @@ func getSystemPing(c *Context, w http.ResponseWriter, r *http.Request) {
}
func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {
var cfg *model.Config
jsonErr := json.NewDecoder(r.Body).Decode(&cfg)
if jsonErr != nil {
c.Err = model.NewAppError("testEmail", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusBadRequest)
return
cfg := model.ConfigFromJSON(r.Body)
if cfg == nil {
cfg = c.App.Config()
}
if checkHasNilFields(&cfg.EmailSettings) {
@@ -454,11 +452,9 @@ func getSupportedTimezones(c *Context, w http.ResponseWriter, r *http.Request) {
}
func testS3(c *Context, w http.ResponseWriter, r *http.Request) {
var cfg *model.Config
jsonErr := json.NewDecoder(r.Body).Decode(&cfg)
if jsonErr != nil {
c.Err = model.NewAppError("testS3", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusBadRequest)
return
cfg := model.ConfigFromJSON(r.Body)
if cfg == nil {
cfg = c.App.Config()
}
if checkHasNilFields(&cfg.FileSettings) {