From 1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 6 Sep 2017 17:12:54 -0500 Subject: app type transition (#7167) --- api4/context.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'api4/context.go') diff --git a/api4/context.go b/api4/context.go index 2c0e54ea0..f8768b11e 100644 --- a/api4/context.go +++ b/api4/context.go @@ -20,6 +20,7 @@ import ( ) type Context struct { + App *app.App Session model.Session Params *ApiParams Err *model.AppError @@ -87,6 +88,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { l4g.Debug("%v - %v", r.Method, r.URL.Path) c := &Context{} + c.App = app.Global() c.T, _ = utils.GetTranslationsAndLocale(w, r) c.RequestId = model.NewId() c.IpAddress = utils.GetIpAddress(r) @@ -138,7 +140,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if len(token) != 0 { - session, err := app.GetSession(token) + session, err := app.Global().GetSession(token) if err != nil { l4g.Error(utils.T("api.context.invalid_session.error"), err.Error()) @@ -199,7 +201,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (c *Context) LogAudit(extraInfo string) { audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id} - if r := <-app.Srv.Store.Audit().Save(audit); r.Err != nil { + if r := <-app.Global().Srv.Store.Audit().Save(audit); r.Err != nil { c.LogError(r.Err) } } @@ -211,7 +213,7 @@ func (c *Context) LogAuditWithUserId(userId, extraInfo string) { } audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id} - if r := <-app.Srv.Store.Audit().Save(audit); r.Err != nil { + if r := <-app.Global().Srv.Store.Audit().Save(audit); r.Err != nil { c.LogError(r.Err) } } @@ -259,7 +261,7 @@ func (c *Context) MfaRequired() { return } - if user, err := app.GetUser(c.Session.UserId); err != nil { + if user, err := app.Global().GetUser(c.Session.UserId); err != nil { c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "MfaRequired", http.StatusUnauthorized) return } else { -- cgit v1.2.3-1-g7c22