MM-49564: Drafts upsert in the Store vs App layer (#22530)

* MM-49564: Upsert in the Store vs App layer

Refactor drafts so that Upserting a draft would happen in the DB and not
in the app layer.

* Fixes mocks

* Fixes tests

* Fixes translations

* Fixes tests

* Update tests

* Fixes tests

* Addresses review comments

- renames Save => Upsert
- removes Sleep from tests

* Fixes flaky test

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Kyriakos Z
2023-04-01 10:32:40 +03:00
committed by GitHub
parent 4a3c853636
commit 4d2ed469bf
15 changed files with 113 additions and 395 deletions

View File

@@ -62,7 +62,7 @@ func upsertDraft(c *Context, w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusCreated)
if err := json.NewEncoder(w).Encode(dt); err != nil {
mlog.Warn("Error while writing response", mlog.Err(err))
c.Logger.Warn("Error while writing response", mlog.Err(err))
}
}
@@ -94,7 +94,7 @@ func getDrafts(c *Context, w http.ResponseWriter, r *http.Request) {
}
if err := json.NewEncoder(w).Encode(drafts); err != nil {
mlog.Warn("Error while writing response", mlog.Err(err))
c.Logger.Warn("Error while writing response", mlog.Err(err))
}
}