From 51dc5fa36ed2d5afa72bf630d66693bd99acb916 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Sat, 28 Jul 2018 14:27:55 +0800 Subject: [MM-10621] Set createAt timestamp on file upload api call to secure upload order of files (#9170) * set createAt timestamp on file upload api call to secure upload order of files * fix test on plugin hooks --- api4/file.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'api4') diff --git a/api4/file.go b/api4/file.go index 3c0944b89..f73a54fb4 100644 --- a/api4/file.go +++ b/api4/file.go @@ -10,6 +10,7 @@ import ( "net/url" "strconv" "strings" + "time" "github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/model" @@ -69,6 +70,7 @@ func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) { return } + now := time.Now() var resStruct *model.FileUploadResponse var appErr *model.AppError @@ -100,6 +102,7 @@ func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) { []io.ReadCloser{r.Body}, []string{filename}, []string{}, + now, ) } else { m := r.MultipartForm @@ -120,7 +123,14 @@ func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) { return } - resStruct, appErr = c.App.UploadMultipartFiles(FILE_TEAM_ID, channelId, c.Session.UserId, m.File["files"], m.Value["client_ids"]) + resStruct, appErr = c.App.UploadMultipartFiles( + FILE_TEAM_ID, + channelId, + c.Session.UserId, + m.File["files"], + m.Value["client_ids"], + now, + ) } if appErr != nil { -- cgit v1.2.3-1-g7c22