remove einterface gets (#7455)
Этот коммит содержится в:
27
api/admin.go
27
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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
api/user.go
11
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
|
||||
|
||||
Ссылка в новой задаче
Block a user