From ac74066f0e4f3d62f2d4645c3fa34b88c13958d1 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 19 Sep 2017 18:31:35 -0500 Subject: remove einterface gets (#7455) --- api4/brand.go | 4 ++-- api4/cluster.go | 2 +- api4/context.go | 11 +++++------ api4/elasticsearch.go | 4 ++-- api4/ldap.go | 4 ++-- api4/saml.go | 2 +- api4/system.go | 10 +++++----- api4/system_test.go | 3 +-- api4/user.go | 2 +- 9 files changed, 20 insertions(+), 22 deletions(-) (limited to 'api4') diff --git a/api4/brand.go b/api4/brand.go index bc1ddd2cc..ef4ea25b5 100644 --- a/api4/brand.go +++ b/api4/brand.go @@ -22,7 +22,7 @@ func InitBrand() { func getBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { // No permission check required - if img, err := app.GetBrandImage(); err != nil { + if img, err := c.App.GetBrandImage(); err != nil { w.WriteHeader(http.StatusNotFound) w.Write(nil) } else { @@ -60,7 +60,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 } diff --git a/api4/cluster.go b/api4/cluster.go index 0b119ad1a..c802d2a7e 100644 --- a/api4/cluster.go +++ b/api4/cluster.go @@ -24,6 +24,6 @@ func getClusterStatus(c *Context, w http.ResponseWriter, r *http.Request) { return } - infos := app.GetClusterStatus() + infos := c.App.GetClusterStatus() w.Write([]byte(model.ClusterInfosToJson(infos))) } diff --git a/api4/context.go b/api4/context.go index 04eb9bbc3..cd32bc7b1 100644 --- a/api4/context.go +++ b/api4/context.go @@ -14,7 +14,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" ) @@ -184,17 +183,17 @@ 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() } } - if einterfaces.GetMetricsInterface() != nil { - einterfaces.GetMetricsInterface().IncrementHttpRequest() + if c.App.Metrics != nil { + c.App.Metrics.IncrementHttpRequest() if r.URL.Path != model.API_URL_SUFFIX+"/websocket" { elapsed := float64(time.Since(now)) / float64(time.Second) - einterfaces.GetMetricsInterface().ObserveHttpRequestDuration(elapsed) + c.App.Metrics.ObserveHttpRequestDuration(elapsed) } } } diff --git a/api4/elasticsearch.go b/api4/elasticsearch.go index c4d059af9..cfa8292b6 100644 --- a/api4/elasticsearch.go +++ b/api4/elasticsearch.go @@ -30,7 +30,7 @@ func testElasticsearch(c *Context, w http.ResponseWriter, r *http.Request) { return } - if err := app.TestElasticsearch(cfg); err != nil { + if err := c.App.TestElasticsearch(cfg); err != nil { c.Err = err return } @@ -44,7 +44,7 @@ func purgeElasticsearchIndexes(c *Context, w http.ResponseWriter, r *http.Reques return } - if err := app.PurgeElasticsearchIndexes(); err != nil { + if err := c.App.PurgeElasticsearchIndexes(); err != nil { c.Err = err return } diff --git a/api4/ldap.go b/api4/ldap.go index 84c0eff28..6ed581783 100644 --- a/api4/ldap.go +++ b/api4/ldap.go @@ -25,7 +25,7 @@ func syncLdap(c *Context, w http.ResponseWriter, r *http.Request) { return } - app.SyncLdap() + c.App.SyncLdap() ReturnStatusOK(w) } @@ -36,7 +36,7 @@ func testLdap(c *Context, w http.ResponseWriter, r *http.Request) { return } - if err := app.TestLdap(); err != nil { + if err := c.App.TestLdap(); err != nil { c.Err = err return } diff --git a/api4/saml.go b/api4/saml.go index d16bef787..0fae1965b 100644 --- a/api4/saml.go +++ b/api4/saml.go @@ -30,7 +30,7 @@ func InitSaml() { } func getSamlMetadata(c *Context, w http.ResponseWriter, r *http.Request) { - metadata, err := app.GetSamlMetadata() + metadata, err := c.App.GetSamlMetadata() if err != nil { c.Err = err return diff --git a/api4/system.go b/api4/system.go index b50dc97a5..766ea09ee 100644 --- a/api4/system.go +++ b/api4/system.go @@ -94,7 +94,7 @@ func getConfig(c *Context, w http.ResponseWriter, r *http.Request) { return } - cfg := app.GetConfig() + cfg := c.App.GetConfig() w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Write([]byte(cfg.ToJson())) @@ -106,7 +106,7 @@ func configReload(c *Context, w http.ResponseWriter, r *http.Request) { return } - app.ReloadConfig() + c.App.ReloadConfig() w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") ReturnStatusOK(w) @@ -124,7 +124,7 @@ func updateConfig(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 @@ -132,7 +132,7 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) { c.LogAudit("updateConfig") - cfg = app.GetConfig() + cfg = c.App.GetConfig() w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Write([]byte(cfg.ToJson())) @@ -188,7 +188,7 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) { return } - lines, err := app.GetLogs(c.Params.Page, c.Params.PerPage) + lines, err := c.App.GetLogs(c.Params.Page, c.Params.PerPage) if err != nil { c.Err = err return diff --git a/api4/system_test.go b/api4/system_test.go index c960f8689..426752b58 100644 --- a/api4/system_test.go +++ b/api4/system_test.go @@ -6,7 +6,6 @@ import ( "testing" l4g "github.com/alecthomas/log4go" - "github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/utils" ) @@ -108,7 +107,7 @@ func TestUpdateConfig(t *testing.T) { defer TearDown() Client := th.Client - cfg := app.GetConfig() + cfg := th.App.GetConfig() _, resp := Client.UpdateConfig(cfg) CheckForbiddenStatus(t, resp) diff --git a/api4/user.go b/api4/user.go index cb1ae0fa3..e62091320 100644 --- a/api4/user.go +++ b/api4/user.go @@ -947,7 +947,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 -- cgit v1.2.3-1-g7c22