Remove all remaining occurences of fakeApp (#17661)
* Remove all remaining occurences of fakeApp Migrated any remaining methods under server. And for everything else, renamed fakeApp to app. The word fakeApp is confusing and we should just call it for what it is - an app. https://focalboard-community.octo.mattermost.com/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=639a0bc1-4401-43d5-81ec-0dd54e796d9a ```release-note NONE ``` * fix tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0bc065d147
Коммит
a4f7df6f6e
@@ -20,11 +20,11 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
func (a *App) ServePluginRequest(w http.ResponseWriter, r *http.Request) {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
func (s *Server) ServePluginRequest(w http.ResponseWriter, r *http.Request) {
|
||||
pluginsEnvironment := s.GetPluginsEnvironment()
|
||||
if pluginsEnvironment == nil {
|
||||
err := model.NewAppError("ServePluginRequest", "app.plugin.disabled.app_error", nil, "Enable plugins to serve plugin requests", http.StatusNotImplemented)
|
||||
a.Log().Error(err.Error())
|
||||
s.Log.Error(err.Error())
|
||||
w.WriteHeader(err.StatusCode)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte(err.ToJson()))
|
||||
@@ -34,7 +34,7 @@ func (a *App) ServePluginRequest(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
hooks, err := pluginsEnvironment.HooksForPlugin(params["plugin_id"])
|
||||
if err != nil {
|
||||
a.Log().Error("Access to route for non-existent plugin",
|
||||
s.Log.Error("Access to route for non-existent plugin",
|
||||
mlog.String("missing_plugin_id", params["plugin_id"]),
|
||||
mlog.String("url", r.URL.String()),
|
||||
mlog.Err(err))
|
||||
@@ -42,7 +42,7 @@ func (a *App) ServePluginRequest(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
a.servePluginRequest(w, r, hooks.ServeHTTP)
|
||||
s.servePluginRequest(w, r, hooks.ServeHTTP)
|
||||
}
|
||||
|
||||
func (a *App) ServeInterPluginRequest(w http.ResponseWriter, r *http.Request, sourcePluginId, destinationPluginId string) {
|
||||
@@ -81,7 +81,7 @@ func (a *App) ServeInterPluginRequest(w http.ResponseWriter, r *http.Request, so
|
||||
|
||||
// ServePluginPublicRequest serves public plugin files
|
||||
// at the URL http(s)://$SITE_URL/plugins/$PLUGIN_ID/public/{anything}
|
||||
func (a *App) ServePluginPublicRequest(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) ServePluginPublicRequest(w http.ResponseWriter, r *http.Request) {
|
||||
if strings.HasSuffix(r.URL.Path, "/") {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
@@ -91,7 +91,7 @@ func (a *App) ServePluginPublicRequest(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
pluginID := vars["plugin_id"]
|
||||
|
||||
pluginsEnv := a.GetPluginsEnvironment()
|
||||
pluginsEnv := s.GetPluginsEnvironment()
|
||||
|
||||
// Check if someone has nullified the pluginsEnv in the meantime
|
||||
if pluginsEnv == nil {
|
||||
@@ -115,11 +115,11 @@ func (a *App) ServePluginPublicRequest(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, publicFile)
|
||||
}
|
||||
|
||||
func (a *App) servePluginRequest(w http.ResponseWriter, r *http.Request, handler func(*plugin.Context, http.ResponseWriter, *http.Request)) {
|
||||
func (s *Server) servePluginRequest(w http.ResponseWriter, r *http.Request, handler func(*plugin.Context, http.ResponseWriter, *http.Request)) {
|
||||
token := ""
|
||||
context := &plugin.Context{
|
||||
RequestId: model.NewId(),
|
||||
IpAddress: utils.GetIPAddress(r, a.Config().ServiceSettings.TrustedProxyIPHeader),
|
||||
IpAddress: utils.GetIPAddress(r, s.Config().ServiceSettings.TrustedProxyIPHeader),
|
||||
AcceptLanguage: r.Header.Get("Accept-Language"),
|
||||
UserAgent: r.UserAgent(),
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func (a *App) servePluginRequest(w http.ResponseWriter, r *http.Request, handler
|
||||
|
||||
r.Header.Del("Mattermost-User-Id")
|
||||
if token != "" {
|
||||
session, err := a.GetSession(token)
|
||||
session, err := New(ServerConnector(s)).GetSession(token)
|
||||
defer ReturnSessionToPool(session)
|
||||
|
||||
csrfCheckPassed := false
|
||||
@@ -184,10 +184,10 @@ func (a *App) servePluginRequest(w http.ResponseWriter, r *http.Request, handler
|
||||
mlog.String("user_id", userID),
|
||||
}
|
||||
|
||||
if *a.Config().ServiceSettings.ExperimentalStrictCSRFEnforcement {
|
||||
a.Log().Warn(csrfErrorMessage, fields...)
|
||||
if *s.Config().ServiceSettings.ExperimentalStrictCSRFEnforcement {
|
||||
s.Log.Warn(csrfErrorMessage, fields...)
|
||||
} else {
|
||||
a.Log().Debug(csrfErrorMessage, fields...)
|
||||
s.Log.Debug(csrfErrorMessage, fields...)
|
||||
csrfCheckPassed = true
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (a *App) servePluginRequest(w http.ResponseWriter, r *http.Request, handler
|
||||
|
||||
params := mux.Vars(r)
|
||||
|
||||
subpath, _ := utils.GetSubpathFromConfig(a.Config())
|
||||
subpath, _ := utils.GetSubpathFromConfig(s.Config())
|
||||
|
||||
newQuery := r.URL.Query()
|
||||
newQuery.Del("access_token")
|
||||
|
||||
Ссылка в новой задаче
Block a user