Migrate to stateless app.App (#17542)
* add request context * move initialialization to server * use app interface instead of global app functions * remove app context from webconn * cleanup * remove duplicated services * move context to separate package * remove finalize init method and move content to NewServer function * restart workers and schedulers after adding license for tests * reflect review comments Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c09369f14a
Коммит
5ea06e51d0
@@ -47,7 +47,7 @@ func createUpload(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if !c.App.SessionHasPermissionToChannel(*c.App.Session(), us.ChannelId, model.PERMISSION_UPLOAD_FILE) {
|
||||
if !c.App.SessionHasPermissionToChannel(*c.AppContext.Session(), us.ChannelId, model.PERMISSION_UPLOAD_FILE) {
|
||||
c.SetPermissionError(model.PERMISSION_UPLOAD_FILE)
|
||||
return
|
||||
}
|
||||
@@ -55,8 +55,8 @@ func createUpload(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
us.Id = model.NewId()
|
||||
if c.App.Session().UserId != "" {
|
||||
us.UserId = c.App.Session().UserId
|
||||
if c.AppContext.Session().UserId != "" {
|
||||
us.UserId = c.AppContext.Session().UserId
|
||||
}
|
||||
us, err := c.App.CreateUploadSession(us)
|
||||
if err != nil {
|
||||
@@ -81,7 +81,7 @@ func getUpload(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if us.UserId != c.App.Session().UserId && !c.IsSystemAdmin() {
|
||||
if us.UserId != c.AppContext.Session().UserId && !c.IsSystemAdmin() {
|
||||
c.Err = model.NewAppError("getUpload", "api.upload.get_upload.forbidden.app_error", nil, "", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func uploadData(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if us.UserId != c.App.Session().UserId || !c.App.SessionHasPermissionToChannel(*c.App.Session(), us.ChannelId, model.PERMISSION_UPLOAD_FILE) {
|
||||
if us.UserId != c.AppContext.Session().UserId || !c.App.SessionHasPermissionToChannel(*c.AppContext.Session(), us.ChannelId, model.PERMISSION_UPLOAD_FILE) {
|
||||
c.SetPermissionError(model.PERMISSION_UPLOAD_FILE)
|
||||
return
|
||||
}
|
||||
@@ -163,5 +163,5 @@ func doUploadData(c *Context, us *model.UploadSession, r *http.Request) (*model.
|
||||
rd = r.Body
|
||||
}
|
||||
|
||||
return c.App.UploadData(us, rd)
|
||||
return c.App.UploadData(c.AppContext, us, rd)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user