summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-19 18:31:35 -0500
committerGitHub <noreply@github.com>2017-09-19 18:31:35 -0500
commitac74066f0e4f3d62f2d4645c3fa34b88c13958d1 (patch)
tree9e1cb80eae1b4a2e9dcc2272744c4a9db1b4b804 /api
parent7e4ff6adcccc4cc5a8fb8cfa853417ec52bf78f4 (diff)
downloadchat-ac74066f0e4f3d62f2d4645c3fa34b88c13958d1.tar.gz
chat-ac74066f0e4f3d62f2d4645c3fa34b88c13958d1.tar.bz2
chat-ac74066f0e4f3d62f2d4645c3fa34b88c13958d1.zip
remove einterface gets (#7455)
Diffstat (limited to 'api')
-rw-r--r--api/admin.go27
-rw-r--r--api/context.go17
-rw-r--r--api/user.go11
3 files changed, 26 insertions, 29 deletions
diff --git a/api/admin.go b/api/admin.go
index 02b056931..65cea5eb7 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -10,7 +10,6 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/app"
- "github.com/mattermost/mattermost-server/einterfaces"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
"github.com/mssola/user_agent"
@@ -47,7 +46,7 @@ func InitAdmin() {
}
func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
- lines, err := app.GetLogs(0, 10000)
+ lines, err := c.App.GetLogs(0, 10000)
if err != nil {
c.Err = err
return
@@ -57,10 +56,10 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getClusterStatus(c *Context, w http.ResponseWriter, r *http.Request) {
- infos := app.GetClusterStatus()
+ infos := c.App.GetClusterStatus()
- if einterfaces.GetClusterInterface() != nil {
- w.Header().Set(model.HEADER_CLUSTER_ID, einterfaces.GetClusterInterface().GetClusterId())
+ if c.App.Cluster != nil {
+ w.Header().Set(model.HEADER_CLUSTER_ID, c.App.Cluster.GetClusterId())
}
w.Write([]byte(model.ClusterInfosToJson(infos)))
@@ -84,13 +83,13 @@ func getAllAudits(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getConfig(c *Context, w http.ResponseWriter, r *http.Request) {
- cfg := app.GetConfig()
+ cfg := c.App.GetConfig()
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Write([]byte(cfg.ToJson()))
}
func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
- app.ReloadConfig()
+ c.App.ReloadConfig()
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
ReturnStatusOK(w)
}
@@ -113,7 +112,7 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- err := app.SaveConfig(cfg, true)
+ err := c.App.SaveConfig(cfg, true)
if err != nil {
c.Err = err
return
@@ -261,7 +260,7 @@ func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if err := app.SaveBrandImage(imageArray[0]); err != nil {
+ if err := c.App.SaveBrandImage(imageArray[0]); err != nil {
c.Err = err
return
}
@@ -272,7 +271,7 @@ func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
- if img, err := app.GetBrandImage(); err != nil {
+ if img, err := c.App.GetBrandImage(); err != nil {
w.Write(nil)
} else {
w.Header().Set("Content-Type", "image/png")
@@ -289,7 +288,7 @@ func adminResetMfa(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- if err := app.DeactivateMfa(userId); err != nil {
+ if err := c.App.DeactivateMfa(userId); err != nil {
c.Err = err
return
}
@@ -329,7 +328,7 @@ func adminResetPassword(c *Context, w http.ResponseWriter, r *http.Request) {
}
func ldapSyncNow(c *Context, w http.ResponseWriter, r *http.Request) {
- app.SyncLdap()
+ c.App.SyncLdap()
rdata := map[string]string{}
rdata["status"] = "ok"
@@ -337,7 +336,7 @@ func ldapSyncNow(c *Context, w http.ResponseWriter, r *http.Request) {
}
func ldapTest(c *Context, w http.ResponseWriter, r *http.Request) {
- if err := app.TestLdap(); err != nil {
+ if err := c.App.TestLdap(); err != nil {
c.Err = err
return
}
@@ -348,7 +347,7 @@ func ldapTest(c *Context, w http.ResponseWriter, r *http.Request) {
}
func samlMetadata(c *Context, w http.ResponseWriter, r *http.Request) {
- if result, err := app.GetSamlMetadata(); err != nil {
+ if result, err := c.App.GetSamlMetadata(); err != nil {
c.Err = model.NewAppError("loginWithSaml", "api.admin.saml.metadata.app_error", nil, "err="+err.Message, http.StatusInternalServerError)
return
} else {
diff --git a/api/context.go b/api/context.go
index 8cabf38b7..ebc439d31 100644
--- a/api/context.go
+++ b/api/context.go
@@ -15,7 +15,6 @@ import (
goi18n "github.com/nicksnyder/go-i18n/i18n"
"github.com/mattermost/mattermost-server/app"
- "github.com/mattermost/mattermost-server/einterfaces"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/utils"
)
@@ -103,10 +102,6 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
now := time.Now()
l4g.Debug("%v", r.URL.Path)
- if metrics := einterfaces.GetMetricsInterface(); metrics != nil && h.isApi {
- metrics.IncrementHttpRequest()
- }
-
c := &Context{}
c.App = app.Global()
c.T, c.Locale = utils.GetTranslationsAndLocale(w, r)
@@ -114,6 +109,10 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c.IpAddress = utils.GetIpAddress(r)
c.TeamId = mux.Vars(r)["team_id"]
+ if metrics := c.App.Metrics; metrics != nil && h.isApi {
+ metrics.IncrementHttpRequest()
+ }
+
token := ""
isTokenFromQueryString := false
@@ -237,8 +236,8 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(c.Err.StatusCode)
w.Write([]byte(c.Err.ToJson()))
- if einterfaces.GetMetricsInterface() != nil {
- einterfaces.GetMetricsInterface().IncrementHttpError()
+ if c.App.Metrics != nil {
+ c.App.Metrics.IncrementHttpError()
}
} else {
if c.Err.StatusCode == http.StatusUnauthorized {
@@ -250,10 +249,10 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
- if h.isApi && einterfaces.GetMetricsInterface() != nil {
+ if h.isApi && c.App.Metrics != nil {
if r.URL.Path != model.API_URL_SUFFIX_V3+"/users/websocket" {
elapsed := float64(time.Since(now)) / float64(time.Second)
- einterfaces.GetMetricsInterface().ObserveHttpRequestDuration(elapsed)
+ c.App.Metrics.ObserveHttpRequestDuration(elapsed)
}
}
}
diff --git a/api/user.go b/api/user.go
index 1ca46bd56..af012ac2c 100644
--- a/api/user.go
+++ b/api/user.go
@@ -14,7 +14,6 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/app"
- "github.com/mattermost/mattermost-server/einterfaces"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/utils"
@@ -169,7 +168,7 @@ func attachDeviceId(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- app.ClearSessionCacheForUser(c.Session.UserId)
+ c.App.ClearSessionCacheForUser(c.Session.UserId)
c.Session.SetExpireInDays(*utils.Cfg.ServiceSettings.SessionLengthMobileInDays)
maxAge := *utils.Cfg.ServiceSettings.SessionLengthMobileInDays * 60 * 60 * 24
@@ -1075,7 +1074,7 @@ func updateMfa(c *Context, w http.ResponseWriter, r *http.Request) {
}
c.LogAudit("success - activated")
} else {
- if err := app.DeactivateMfa(c.Session.UserId); err != nil {
+ if err := c.App.DeactivateMfa(c.Session.UserId); err != nil {
c.Err = err
return
}
@@ -1126,7 +1125,7 @@ func checkMfa(c *Context, w http.ResponseWriter, r *http.Request) {
}
func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
- samlInterface := einterfaces.GetSamlInterface()
+ samlInterface := c.App.Saml
if samlInterface == nil {
c.Err = model.NewAppError("loginWithSaml", "api.user.saml.not_available.app_error", nil, "", http.StatusFound)
@@ -1169,7 +1168,7 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
}
func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
- samlInterface := einterfaces.GetSamlInterface()
+ samlInterface := c.App.Saml
if samlInterface == nil {
c.Err = model.NewAppError("completeSaml", "api.user.saml.not_available.app_error", nil, "", http.StatusFound)
@@ -1203,7 +1202,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
}
return
} else {
- if err := app.CheckUserAdditionalAuthenticationCriteria(user, ""); err != nil {
+ if err := c.App.CheckUserAdditionalAuthenticationCriteria(user, ""); err != nil {
c.Err = err
c.Err.StatusCode = http.StatusFound
return