Commit 1adfd0e9 authored by Chris's avatar Chris Committed by GitHub

app type transition (#7167)

parent b84bd210
......@@ -67,7 +67,7 @@ func getClusterStatus(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getAllAudits(c *Context, w http.ResponseWriter, r *http.Request) {
if audits, err := app.GetAudits("", 200); err != nil {
if audits, err := c.App.GetAudits("", 200); err != nil {
c.Err = err
return
} else if HandleEtag(audits.Etag(), "Get All Audits", w, r) {
......@@ -96,7 +96,7 @@ func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
}
func invalidateAllCaches(c *Context, w http.ResponseWriter, r *http.Request) {
err := app.InvalidateAllCaches()
err := c.App.InvalidateAllCaches()
if err != nil {
c.Err = err
return
......@@ -124,7 +124,7 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
}
func recycleDatabaseConnection(c *Context, w http.ResponseWriter, r *http.Request) {
app.RecycleDatabaseConnection()
c.App.RecycleDatabaseConnection()
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
ReturnStatusOK(w)
}
......@@ -136,7 +136,7 @@ func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
err := app.TestEmail(c.Session.UserId, cfg)
err := c.App.TestEmail(c.Session.UserId, cfg)
if err != nil {
c.Err = err
return
......@@ -148,7 +148,7 @@ func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getComplianceReports(c *Context, w http.ResponseWriter, r *http.Request) {
crs, err := app.GetComplianceReports(0, 10000)
crs, err := c.App.GetComplianceReports(0, 10000)
if err != nil {
c.Err = err
return
......@@ -165,7 +165,7 @@ func saveComplianceReport(c *Context, w http.ResponseWriter, r *http.Request) {
job.UserId = c.Session.UserId
rjob, err := app.SaveComplianceReport(job)
rjob, err := c.App.SaveComplianceReport(job)
if err != nil {
c.Err = err
return
......@@ -184,7 +184,7 @@ func downloadComplianceReport(c *Context, w http.ResponseWriter, r *http.Request
return
}
job, err := app.GetComplianceReport(id)
job, err := c.App.GetComplianceReport(id)
if err != nil {
c.Err = err
return
......@@ -221,7 +221,7 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
teamId := params["id"]
name := params["name"]
rows, err := app.GetAnalytics(name, teamId)
rows, err := c.App.GetAnalytics(name, teamId)
if err != nil {
c.Err = err
return
......@@ -316,7 +316,7 @@ func adminResetPassword(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if err := app.UpdatePasswordByUserIdSendEmail(userId, newPassword, c.T("api.user.reset_password.method")); err != nil {
if err := c.App.UpdatePasswordByUserIdSendEmail(userId, newPassword, c.T("api.user.reset_password.method")); err != nil {
c.Err = err
return
}
......@@ -412,7 +412,7 @@ func samlCertificateStatus(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getRecentlyActiveUsers(c *Context, w http.ResponseWriter, r *http.Request) {
if profiles, err := app.GetRecentlyActiveUsersForTeam(c.TeamId); err != nil {
if profiles, err := c.App.GetRecentlyActiveUsersForTeam(c.TeamId); err != nil {
c.Err = err
return
} else {
......
......@@ -8,7 +8,6 @@ import (
"strings"
"testing"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils"
......@@ -597,7 +596,7 @@ func TestAdminResetPassword(t *testing.T) {
user := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
LinkUserToTeam(user, team)
store.Must(app.Srv.Store.User().VerifyEmail(user.Id))
store.Must(th.App.Srv.Store.User().VerifyEmail(user.Id))
if _, err := Client.AdminResetPassword("", "newpwd1"); err == nil {
t.Fatal("Should have errored - empty user id")
......@@ -619,7 +618,7 @@ func TestAdminResetPassword(t *testing.T) {
user2 := &model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", AuthData: &authData, AuthService: "random"}
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
LinkUserToTeam(user2, team)
store.Must(app.Srv.Store.User().VerifyEmail(user2.Id))
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
if _, err := Client.AdminResetPassword(user.Id, "newpwd1"); err != nil {
t.Fatal(err)
......
......@@ -60,14 +60,14 @@ type Routes struct {
var BaseRoutes *Routes
func InitRouter() {
app.Srv.Router = mux.NewRouter()
app.Srv.Router.NotFoundHandler = http.HandlerFunc(Handle404)
app.Global().Srv.Router = mux.NewRouter()
app.Global().Srv.Router.NotFoundHandler = http.HandlerFunc(Handle404)
}
func InitApi() {
BaseRoutes = &Routes{}
BaseRoutes.Root = app.Srv.Router
BaseRoutes.ApiRoot = app.Srv.Router.PathPrefix(model.API_URL_SUFFIX_V3).Subrouter()
BaseRoutes.Root = app.Global().Srv.Router
BaseRoutes.ApiRoot = app.Global().Srv.Router.PathPrefix(model.API_URL_SUFFIX_V3).Subrouter()
BaseRoutes.Users = BaseRoutes.ApiRoot.PathPrefix("/users").Subrouter()
BaseRoutes.NeedUser = BaseRoutes.Users.PathPrefix("/{user_id:[A-Za-z0-9]+}").Subrouter()
BaseRoutes.Teams = BaseRoutes.ApiRoot.PathPrefix("/teams").Subrouter()
......@@ -111,7 +111,7 @@ func InitApi() {
InitDeprecated()
// 404 on any api route before web.go has a chance to serve it
app.Srv.Router.Handle("/api/{anything:.*}", http.HandlerFunc(Handle404))
app.Global().Srv.Router.Handle("/api/{anything:.*}", http.HandlerFunc(Handle404))
utils.InitHTML()
......
......@@ -17,6 +17,8 @@ import (
)
type TestHelper struct {
App *app.App
BasicClient *model.Client
BasicTeam *model.Team
BasicUser *model.User
......@@ -32,7 +34,7 @@ type TestHelper struct {
}
func SetupEnterprise() *TestHelper {
if app.Srv == nil {
if app.Global().Srv == nil {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
......@@ -40,17 +42,17 @@ func SetupEnterprise() *TestHelper {
*utils.Cfg.RateLimitSettings.Enable = false
utils.DisableDebugLogForTest()
utils.License().Features.SetDefaults()
app.NewServer()
app.InitStores()
app.Global().NewServer()
app.Global().InitStores()
InitRouter()
wsapi.InitRouter()
app.StartServer()
app.Global().StartServer()
utils.InitHTML()
api4.InitApi(false)
InitApi()
wsapi.InitApi()
utils.EnableDebugLogForTest()
app.Srv.Store.MarkSystemRanUnitTests()
app.Global().Srv.Store.MarkSystemRanUnitTests()
*utils.Cfg.TeamSettings.EnableOpenServer = true
}
......@@ -59,7 +61,7 @@ func SetupEnterprise() *TestHelper {
}
func Setup() *TestHelper {
if app.Srv == nil {
if app.Global().Srv == nil {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
......@@ -70,16 +72,16 @@ func Setup() *TestHelper {
utils.Cfg.EmailSettings.SMTPPort = "2500"
utils.Cfg.EmailSettings.FeedbackEmail = "test@example.com"
utils.DisableDebugLogForTest()
app.NewServer()
app.InitStores()
app.Global().NewServer()
app.Global().InitStores()
InitRouter()
wsapi.InitRouter()
app.StartServer()
app.Global().StartServer()
api4.InitApi(false)
InitApi()
wsapi.InitApi()
utils.EnableDebugLogForTest()
app.Srv.Store.MarkSystemRanUnitTests()
app.Global().Srv.Store.MarkSystemRanUnitTests()
*utils.Cfg.TeamSettings.EnableOpenServer = true
}
......@@ -100,6 +102,7 @@ func ReloadConfigForSetup() {
}
func (me *TestHelper) InitBasic() *TestHelper {
me.App = app.Global()
me.BasicClient = me.CreateClient()
me.BasicUser = me.CreateUser(me.BasicClient)
me.LoginBasic()
......@@ -119,6 +122,7 @@ func (me *TestHelper) InitBasic() *TestHelper {
}
func (me *TestHelper) InitSystemAdmin() *TestHelper {
me.App = app.Global()
me.SystemAdminClient = me.CreateClient()
me.SystemAdminUser = me.CreateUser(me.SystemAdminClient)
me.SystemAdminUser.Password = "Password1"
......@@ -126,7 +130,7 @@ func (me *TestHelper) InitSystemAdmin() *TestHelper {
me.SystemAdminTeam = me.CreateTeam(me.SystemAdminClient)
LinkUserToTeam(me.SystemAdminUser, me.SystemAdminTeam)
me.SystemAdminClient.SetTeamId(me.SystemAdminTeam.Id)
app.UpdateUserRoles(me.SystemAdminUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_ADMIN.Id)
me.App.UpdateUserRoles(me.SystemAdminUser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_ADMIN.Id)
me.SystemAdminChannel = me.CreateChannel(me.SystemAdminClient, me.SystemAdminTeam)
return me
......@@ -168,7 +172,7 @@ func (me *TestHelper) CreateUser(client *model.Client) *model.User {
utils.DisableDebugLogForTest()
ruser := client.Must(client.CreateUser(user, "")).Data.(*model.User)
ruser.Password = "Password1"
store.Must(app.Srv.Store.User().VerifyEmail(ruser.Id))
store.Must(app.Global().Srv.Store.User().VerifyEmail(ruser.Id))
utils.EnableDebugLogForTest()
return ruser
}
......@@ -176,7 +180,7 @@ func (me *TestHelper) CreateUser(client *model.Client) *model.User {
func LinkUserToTeam(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest()
err := app.JoinUserToTeam(team, user, "")
err := app.Global().JoinUserToTeam(team, user, "")
if err != nil {
l4g.Error(err.Error())
l4g.Close()
......@@ -191,7 +195,7 @@ func UpdateUserToTeamAdmin(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest()
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id + " " + model.ROLE_TEAM_ADMIN.Id}
if tmr := <-app.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
if tmr := <-app.Global().Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
utils.EnableDebugLogForTest()
l4g.Error(tmr.Err.Error())
l4g.Close()
......@@ -205,7 +209,7 @@ func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
utils.DisableDebugLogForTest()
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id, Roles: model.ROLE_TEAM_USER.Id}
if tmr := <-app.Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
if tmr := <-app.Global().Srv.Store.Team().UpdateMember(tm); tmr.Err != nil {
utils.EnableDebugLogForTest()
l4g.Error(tmr.Err.Error())
l4g.Close()
......@@ -218,10 +222,10 @@ func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team) {
func MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
utils.DisableDebugLogForTest()
if cmr := <-app.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
if cmr := <-app.Global().Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
cm := cmr.Data.(*model.ChannelMember)
cm.Roles = "channel_admin channel_user"
if sr := <-app.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
if sr := <-app.Global().Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
utils.EnableDebugLogForTest()
panic(sr.Err)
}
......@@ -236,10 +240,10 @@ func MakeUserChannelAdmin(user *model.User, channel *model.Channel) {
func MakeUserChannelUser(user *model.User, channel *model.Channel) {
utils.DisableDebugLogForTest()
if cmr := <-app.Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
if cmr := <-app.Global().Srv.Store.Channel().GetMember(channel.Id, user.Id); cmr.Err == nil {
cm := cmr.Data.(*model.ChannelMember)
cm.Roles = "channel_user"
if sr := <-app.Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
if sr := <-app.Global().Srv.Store.Channel().UpdateMember(cm); sr.Err != nil {
utils.EnableDebugLogForTest()
panic(sr.Err)
}
......@@ -323,7 +327,7 @@ func (me *TestHelper) LoginSystemAdmin() {
}
func TearDown() {
if app.Srv != nil {
app.StopServer()
if app.Global().Srv != nil {
app.Global().StopServer()
}
}
This diff is collapsed.
......@@ -9,7 +9,6 @@ import (
"testing"
"time"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils"
......@@ -404,7 +403,7 @@ func TestUpdateChannel(t *testing.T) {
}
UpdateUserToTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches()
th.App.InvalidateAllCaches()
if _, err := Client.UpdateChannel(channel2); err != nil {
t.Fatal(err)
}
......@@ -412,7 +411,7 @@ func TestUpdateChannel(t *testing.T) {
t.Fatal(err)
}
UpdateUserToNonTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches()
th.App.InvalidateAllCaches()
MakeUserChannelAdmin(th.BasicUser, channel2)
MakeUserChannelAdmin(th.BasicUser, channel3)
......@@ -1188,7 +1187,7 @@ func TestJoinChannelByNameDisabledUser(t *testing.T) {
Client.Must(th.BasicClient.RemoveUserFromTeam(th.BasicTeam.Id, th.BasicUser.Id))
if _, err := app.AddUserToChannel(th.BasicUser, channel1); err == nil {
if _, err := th.App.AddUserToChannel(th.BasicUser, channel1); err == nil {
t.Fatal("shoudn't be able to join channel")
} else {
if err.Id != "api.channel.add_user.to.channel.failed.deleted.app_error" {
......@@ -1406,7 +1405,7 @@ func TestDeleteChannel(t *testing.T) {
UpdateUserToTeamAdmin(th.BasicUser, team)
Client.Login(th.BasicUser.Email, th.BasicUser.Password)
app.InvalidateAllCaches()
th.App.InvalidateAllCaches()
if _, err := Client.DeleteChannel(channel2.Id); err != nil {
t.Fatal(err)
......@@ -1416,7 +1415,7 @@ func TestDeleteChannel(t *testing.T) {
}
UpdateUserToNonTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches()
th.App.InvalidateAllCaches()
utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}})
......@@ -1634,7 +1633,7 @@ func TestAddChannelMember(t *testing.T) {
}
MakeUserChannelAdmin(user1, channel5)
app.InvalidateAllCaches()
th.App.InvalidateAllCaches()
utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults()
......@@ -1659,7 +1658,7 @@ func TestAddChannelMember(t *testing.T) {
}
UpdateUserToTeamAdmin(user1, team)
app.InvalidateAllCaches()
th.App.InvalidateAllCaches()
utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults()
......@@ -1810,7 +1809,7 @@ func TestRemoveChannelMember(t *testing.T) {
}
MakeUserChannelAdmin(user1, channel5)
app.InvalidateAllCaches()
th.App.InvalidateAllCaches()
utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults()
......@@ -1835,7 +1834,7 @@ func TestRemoveChannelMember(t *testing.T) {
}
UpdateUserToTeamAdmin(user1, team)
app.InvalidateAllCaches()
th.App.InvalidateAllCaches()
utils.SetIsLicensed(true)
utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults()
......@@ -2255,7 +2254,7 @@ func TestGetChannelByName(t *testing.T) {
user2 := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Jabba the Hutt", Password: "passwd1"}
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
store.Must(app.Srv.Store.User().VerifyEmail(user2.Id))
store.Must(th.App.Srv.Store.User().VerifyEmail(user2.Id))
Client.SetTeamId(th.BasicTeam.Id)
......@@ -2314,7 +2313,7 @@ func TestViewChannel(t *testing.T) {
func TestGetChannelMembersByIds(t *testing.T) {
th := Setup().InitBasic()
if _, err := app.AddUserToChannel(th.BasicUser2, th.BasicChannel); err != nil {
if _, err := th.App.AddUserToChannel(th.BasicUser2, th.BasicChannel); err != nil {
t.Fatal("Could not add second user to channel")
}
......
......@@ -107,7 +107,7 @@ func TestCliCreateUserWithoutTeam(t *testing.T) {
t.Fatal(err)
}
if result := <-app.Srv.Store.User().GetByEmail(email); result.Err != nil {
if result := <-app.Global().Srv.Store.User().GetByEmail(email); result.Err != nil {
t.Fatal()
} else {
user := result.Data.(*model.User)
......@@ -131,7 +131,7 @@ func TestCliAssignRole(t *testing.T) {
t.Fatal(err)
}
if result := <-app.Srv.Store.User().GetByEmail(th.BasicUser.Email); result.Err != nil {
if result := <-th.App.Srv.Store.User().GetByEmail(th.BasicUser.Email); result.Err != nil {
t.Fatal()
} else {
user := result.Data.(*model.User)
......@@ -369,7 +369,7 @@ func TestCliLeaveTeam(t *testing.T) {
t.Fatal("profile should not be on team")
}
if result := <-app.Srv.Store.Team().GetTeamsByUserId(th.BasicUser.Id); result.Err != nil {
if result := <-th.App.Srv.Store.Team().GetTeamsByUserId(th.BasicUser.Id); result.Err != nil {
teamMembers := result.Data.([]*model.TeamMember)
if len(teamMembers) > 0 {
t.Fatal("Shouldn't be in team")
......
......@@ -34,7 +34,7 @@ func InitCommand() {
}
func listCommands(c *Context, w http.ResponseWriter, r *http.Request) {
commands, err := app.ListAutocompleteCommands(c.TeamId, c.T)
commands, err := c.App.ListAutocompleteCommands(c.TeamId, c.T)
if err != nil {
c.Err = err
return
......@@ -56,7 +56,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
}
if len(commandArgs.ChannelId) > 0 {
if !app.SessionHasPermissionToChannel(c.Session, commandArgs.ChannelId, model.PERMISSION_USE_SLASH_COMMANDS) {
if !c.App.SessionHasPermissionToChannel(c.Session, commandArgs.ChannelId, model.PERMISSION_USE_SLASH_COMMANDS) {
c.SetPermissionError(model.PERMISSION_USE_SLASH_COMMANDS)
return
}
......@@ -68,7 +68,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
commandArgs.Session = c.Session
commandArgs.SiteURL = c.GetSiteURLHeader()
response, err := app.ExecuteCommand(commandArgs)
response, err := c.App.ExecuteCommand(commandArgs)
if err != nil {
c.Err = err
return
......@@ -95,7 +95,7 @@ func createCommand(c *Context, w http.ResponseWriter, r *http.Request) {
cmd.CreatorId = c.Session.UserId
cmd.TeamId = c.TeamId
rcmd, err := app.CreateCommand(cmd)
rcmd, err := c.App.CreateCommand(cmd)
if err != nil {
c.Err = err
return
......@@ -115,7 +115,7 @@ func updateCommand(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAudit("attempt")
oldCmd, err := app.GetCommand(cmd.Id)
oldCmd, err := c.App.GetCommand(cmd.Id)
if err != nil {
c.Err = err
return
......@@ -138,7 +138,7 @@ func updateCommand(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
rcmd, err := app.UpdateCommand(oldCmd, cmd)
rcmd, err := c.App.UpdateCommand(oldCmd, cmd)
if err != nil {
c.Err = err
return
......@@ -155,7 +155,7 @@ func listTeamCommands(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
cmds, err := app.ListTeamCommands(c.TeamId)
cmds, err := c.App.ListTeamCommands(c.TeamId)
if err != nil {
c.Err = err
return
......@@ -175,7 +175,7 @@ func regenCommandToken(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAudit("attempt")
cmd, err := app.GetCommand(id)
cmd, err := c.App.GetCommand(id)
if err != nil {
c.Err = err
return
......@@ -198,7 +198,7 @@ func regenCommandToken(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
rcmd, err := app.RegenCommandToken(cmd)
rcmd, err := c.App.RegenCommandToken(cmd)
if err != nil {
c.Err = err
return
......@@ -218,7 +218,7 @@ func deleteCommand(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAudit("attempt")
cmd, err := app.GetCommand(id)
cmd, err := c.App.GetCommand(id)
if err != nil {
c.Err = err
return
......@@ -241,7 +241,7 @@ func deleteCommand(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
err = app.DeleteCommand(cmd.Id)
err = c.App.DeleteCommand(cmd.Id)
if err != nil {
c.Err = err
return
......
......@@ -4,9 +4,10 @@
package api
import (
"testing"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
"testing"
)
func TestHelpCommand(t *testing.T) {
......
......@@ -4,9 +4,10 @@
package api
import (
"github.com/mattermost/platform/model"
"strings"
"testing"
"github.com/mattermost/platform/model"
)
func TestMsgCommands(t *testing.T) {
......
......@@ -21,6 +21,7 @@ import (
)
type Context struct {
App *app.App
Session model.Session
RequestId string
IpAddress string
......@@ -107,6 +108,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
c := &Context{}
c.App = app.Global()
c.T, c.Locale = utils.GetTranslationsAndLocale(w, r)
c.RequestId = model.NewId()
c.IpAddress = utils.GetIpAddress(r)
......@@ -165,7 +167,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())
......@@ -206,8 +208,8 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
if c.Err == nil && h.isUserActivity && token != "" && len(c.Session.UserId) > 0 {