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
@@ -40,21 +40,21 @@ func connectWebSocket(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
// If the queues are empty, they are initialized in the constructor.
|
||||
cfg := &app.WebConnConfig{
|
||||
WebSocket: ws,
|
||||
Session: *c.App.Session(),
|
||||
TFunc: c.App.T,
|
||||
Session: *c.AppContext.Session(),
|
||||
TFunc: c.AppContext.T,
|
||||
Locale: "",
|
||||
Active: true,
|
||||
}
|
||||
|
||||
if *c.App.Config().ServiceSettings.EnableReliableWebSockets {
|
||||
cfg.ConnectionID = r.URL.Query().Get(connectionIDParam)
|
||||
if cfg.ConnectionID == "" || c.App.Session().UserId == "" {
|
||||
if cfg.ConnectionID == "" || c.AppContext.Session().UserId == "" {
|
||||
// If not present, we assume client is not capable yet, or it's a fresh connection.
|
||||
// We just create a new ID.
|
||||
cfg.ConnectionID = model.NewId()
|
||||
// In case of fresh connection id, sequence number is already zero.
|
||||
} else {
|
||||
cfg, err = c.App.PopulateWebConnConfig(cfg, r.URL.Query().Get(sequenceNumberParam))
|
||||
cfg, err = c.App.PopulateWebConnConfig(c.AppContext.Session(), cfg, r.URL.Query().Get(sequenceNumberParam))
|
||||
if err != nil {
|
||||
mlog.Warn("Error while populating webconn config", mlog.String("id", r.URL.Query().Get(connectionIDParam)), mlog.Err(err))
|
||||
ws.Close()
|
||||
@@ -64,7 +64,7 @@ func connectWebSocket(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
wc := c.App.NewWebConn(cfg)
|
||||
if c.App.Session().UserId != "" {
|
||||
if c.AppContext.Session().UserId != "" {
|
||||
c.App.HubRegister(wc)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user