1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-07-03 23:30:29 +02:00

Store blocks modified_by userID

This commit is contained in:
Chen-I Lim
2021-01-11 18:53:08 -08:00
parent 19eaa56870
commit f2e8bc8285
10 changed files with 377 additions and 242 deletions

View File

@ -78,6 +78,19 @@ func (a *API) handleGetBlocks(w http.ResponseWriter, r *http.Request) {
jsonBytesResponse(w, http.StatusOK, json)
}
func stampModifiedByUser(r *http.Request, blocks []model.Block) {
ctx := r.Context()
session := ctx.Value("session").(*model.Session)
userID := session.UserID
if userID == "single-user" {
userID = ""
}
for i := range blocks {
blocks[i].ModifiedBy = userID
}
}
func (a *API) handlePostBlocks(w http.ResponseWriter, r *http.Request) {
requestBody, err := ioutil.ReadAll(r.Body)
if err != nil {
@ -129,6 +142,8 @@ func (a *API) handlePostBlocks(w http.ResponseWriter, r *http.Request) {
}
}
stampModifiedByUser(r, blocks)
err = a.app().InsertBlocks(blocks)
if err != nil {
log.Printf(`ERROR: %v, REQUEST: %v`, err, r)
@ -349,6 +364,8 @@ func (a *API) handleImport(w http.ResponseWriter, r *http.Request) {
return
}
stampModifiedByUser(r, blocks)
err = a.app().InsertBlocks(blocks)
if err != nil {
log.Printf(`ERROR: %v, REQUEST: %v`, err, r)