MM-21898 - Part 1: Generate and use an interface instead of *A… (#13840)
* Generate and use an interface instead of *App
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
66fc096768
Коммит
17523fa5d9
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
App *app.App
|
||||
App app.AppIface
|
||||
Log *mlog.Logger
|
||||
Params *Params
|
||||
Err *model.AppError
|
||||
@@ -24,20 +24,20 @@ type Context struct {
|
||||
}
|
||||
|
||||
func (c *Context) LogAudit(extraInfo string) {
|
||||
audit := &model.Audit{UserId: c.App.Session.UserId, IpAddress: c.App.IpAddress, Action: c.App.Path, ExtraInfo: extraInfo, SessionId: c.App.Session.Id}
|
||||
if err := c.App.Srv.Store.Audit().Save(audit); err != nil {
|
||||
audit := &model.Audit{UserId: c.App.Session().UserId, IpAddress: c.App.IpAddress(), Action: c.App.Path(), ExtraInfo: extraInfo, SessionId: c.App.Session().Id}
|
||||
if err := c.App.Srv().Store.Audit().Save(audit); err != nil {
|
||||
c.LogError(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Context) LogAuditWithUserId(userId, extraInfo string) {
|
||||
|
||||
if len(c.App.Session.UserId) > 0 {
|
||||
extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.App.Session.UserId)
|
||||
if len(c.App.Session().UserId) > 0 {
|
||||
extraInfo = strings.TrimSpace(extraInfo + " session_user=" + c.App.Session().UserId)
|
||||
}
|
||||
|
||||
audit := &model.Audit{UserId: userId, IpAddress: c.App.IpAddress, Action: c.App.Path, ExtraInfo: extraInfo, SessionId: c.App.Session.Id}
|
||||
if err := c.App.Srv.Store.Audit().Save(audit); err != nil {
|
||||
audit := &model.Audit{UserId: userId, IpAddress: c.App.IpAddress(), Action: c.App.Path(), ExtraInfo: extraInfo, SessionId: c.App.Session().Id}
|
||||
if err := c.App.Srv().Store.Audit().Save(audit); err != nil {
|
||||
c.LogError(err)
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func (c *Context) LogAuditWithUserId(userId, extraInfo string) {
|
||||
func (c *Context) LogError(err *model.AppError) {
|
||||
// Filter out 404s, endless reconnects and browser compatibility errors
|
||||
if err.StatusCode == http.StatusNotFound ||
|
||||
(c.App.Path == "/api/v3/users/websocket" && err.StatusCode == http.StatusUnauthorized) ||
|
||||
(c.App.Path() == "/api/v3/users/websocket" && err.StatusCode == http.StatusUnauthorized) ||
|
||||
err.Id == "web.check_browser_compatibility.app_error" {
|
||||
c.LogDebug(err)
|
||||
} else {
|
||||
@@ -82,19 +82,19 @@ func (c *Context) LogDebug(err *model.AppError) {
|
||||
}
|
||||
|
||||
func (c *Context) IsSystemAdmin() bool {
|
||||
return c.App.SessionHasPermissionTo(c.App.Session, model.PERMISSION_MANAGE_SYSTEM)
|
||||
return c.App.SessionHasPermissionTo(*c.App.Session(), model.PERMISSION_MANAGE_SYSTEM)
|
||||
}
|
||||
|
||||
func (c *Context) SessionRequired() {
|
||||
if !*c.App.Config().ServiceSettings.EnableUserAccessTokens &&
|
||||
c.App.Session.Props[model.SESSION_PROP_TYPE] == model.SESSION_TYPE_USER_ACCESS_TOKEN &&
|
||||
c.App.Session.Props[model.SESSION_PROP_IS_BOT] != model.SESSION_PROP_IS_BOT_VALUE {
|
||||
c.App.Session().Props[model.SESSION_PROP_TYPE] == model.SESSION_TYPE_USER_ACCESS_TOKEN &&
|
||||
c.App.Session().Props[model.SESSION_PROP_IS_BOT] != model.SESSION_PROP_IS_BOT_VALUE {
|
||||
|
||||
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "UserAccessToken", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
if len(c.App.Session.UserId) == 0 {
|
||||
if len(c.App.Session().UserId) == 0 {
|
||||
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "UserRequired", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
@@ -107,11 +107,11 @@ func (c *Context) MfaRequired() {
|
||||
}
|
||||
|
||||
// OAuth integrations are excepted
|
||||
if c.App.Session.IsOAuth {
|
||||
if c.App.Session().IsOAuth {
|
||||
return
|
||||
}
|
||||
|
||||
if user, err := c.App.GetUser(c.App.Session.UserId); err != nil {
|
||||
if user, err := c.App.GetUser(c.App.Session().UserId); err != nil {
|
||||
c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "MfaRequired", http.StatusUnauthorized)
|
||||
return
|
||||
} else {
|
||||
@@ -127,7 +127,7 @@ func (c *Context) MfaRequired() {
|
||||
|
||||
// Special case to let user get themself
|
||||
subpath, _ := utils.GetSubpathFromConfig(c.App.Config())
|
||||
if c.App.Path == path.Join(subpath, "/api/v4/users/me") {
|
||||
if c.App.Path() == path.Join(subpath, "/api/v4/users/me") {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ func (c *Context) SetCommandNotFoundError() {
|
||||
}
|
||||
|
||||
func (c *Context) HandleEtag(etag string, routeName string, w http.ResponseWriter, r *http.Request) bool {
|
||||
metrics := c.App.Metrics
|
||||
metrics := c.App.Metrics()
|
||||
if et := r.Header.Get(model.HEADER_ETAG_CLIENT); len(etag) > 0 {
|
||||
if et == etag {
|
||||
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
||||
@@ -224,7 +224,7 @@ func (c *Context) RequireUserId() *Context {
|
||||
}
|
||||
|
||||
if c.Params.UserId == model.ME {
|
||||
c.Params.UserId = c.App.Session.UserId
|
||||
c.Params.UserId = c.App.Session().UserId
|
||||
}
|
||||
|
||||
if len(c.Params.UserId) != 26 {
|
||||
|
||||
@@ -82,14 +82,16 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
c.App = app.New(
|
||||
h.GetGlobalAppOptions()...,
|
||||
)
|
||||
c.App.T, _ = utils.GetTranslationsAndLocale(w, r)
|
||||
c.App.RequestId = requestID
|
||||
c.App.IpAddress = utils.GetIpAddress(r, c.App.Config().ServiceSettings.TrustedProxyIPHeader)
|
||||
c.App.UserAgent = r.UserAgent()
|
||||
c.App.AcceptLanguage = r.Header.Get("Accept-Language")
|
||||
|
||||
t, _ := utils.GetTranslationsAndLocale(w, r)
|
||||
c.App.SetT(t)
|
||||
c.App.SetRequestId(requestID)
|
||||
c.App.SetIpAddress(utils.GetIpAddress(r, c.App.Config().ServiceSettings.TrustedProxyIPHeader))
|
||||
c.App.SetUserAgent(r.UserAgent())
|
||||
c.App.SetAcceptLanguage(r.Header.Get("Accept-Language"))
|
||||
c.App.SetPath(r.URL.Path)
|
||||
c.Params = ParamsFromRequest(r)
|
||||
c.App.Path = r.URL.Path
|
||||
c.Log = c.App.Log
|
||||
c.Log = c.App.Log()
|
||||
|
||||
// Set the max request body size to be equal to MaxFileSize.
|
||||
// Ideally, non-file request bodies should be smaller than file request bodies,
|
||||
@@ -103,7 +105,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
siteURLHeader := app.GetProtocol(r) + "://" + r.Host + subpath
|
||||
c.SetSiteURLHeader(siteURLHeader)
|
||||
|
||||
w.Header().Set(model.HEADER_REQUEST_ID, c.App.RequestId)
|
||||
w.Header().Set(model.HEADER_REQUEST_ID, c.App.RequestId())
|
||||
w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, c.App.ClientConfigHash(), c.App.License() != nil))
|
||||
|
||||
if *c.App.Config().ServiceSettings.TLSStrictTransport {
|
||||
@@ -142,22 +144,22 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
} else if !session.IsOAuth && tokenLocation == app.TokenLocationQueryString {
|
||||
c.Err = model.NewAppError("ServeHTTP", "api.context.token_provided.app_error", nil, "token="+token, http.StatusUnauthorized)
|
||||
} else {
|
||||
c.App.Session = *session
|
||||
c.App.SetSession(session)
|
||||
}
|
||||
|
||||
// Rate limit by UserID
|
||||
if c.App.Srv.RateLimiter != nil && c.App.Srv.RateLimiter.UserIdRateLimit(c.App.Session.UserId, w) {
|
||||
if c.App.Srv().RateLimiter != nil && c.App.Srv().RateLimiter.UserIdRateLimit(c.App.Session().UserId, w) {
|
||||
return
|
||||
}
|
||||
|
||||
h.checkCSRFToken(c, r, token, tokenLocation, session)
|
||||
}
|
||||
|
||||
c.Log = c.App.Log.With(
|
||||
mlog.String("path", c.App.Path),
|
||||
mlog.String("request_id", c.App.RequestId),
|
||||
mlog.String("ip_addr", c.App.IpAddress),
|
||||
mlog.String("user_id", c.App.Session.UserId),
|
||||
c.Log = c.App.Log().With(
|
||||
mlog.String("path", c.App.Path()),
|
||||
mlog.String("request_id", c.App.RequestId()),
|
||||
mlog.String("ip_addr", c.App.IpAddress()),
|
||||
mlog.String("user_id", c.App.Session().UserId),
|
||||
mlog.String("method", r.Method),
|
||||
)
|
||||
|
||||
@@ -169,7 +171,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
c.MfaRequired()
|
||||
}
|
||||
|
||||
if c.Err == nil && h.DisableWhenBusy && c.App.Srv.Busy.IsBusy() {
|
||||
if c.Err == nil && h.DisableWhenBusy && c.App.Srv().Busy.IsBusy() {
|
||||
c.SetServerBusyError()
|
||||
}
|
||||
|
||||
@@ -180,7 +182,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// Handle errors that have occurred
|
||||
if c.Err != nil {
|
||||
c.Err.Translate(c.App.T)
|
||||
c.Err.RequestId = c.App.RequestId
|
||||
c.Err.RequestId = c.App.RequestId()
|
||||
|
||||
if c.Err.Id == "api.context.session_expired.app_error" {
|
||||
c.LogInfo(c.Err)
|
||||
@@ -212,18 +214,18 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
utils.RenderWebAppError(c.App.Config(), w, r, c.Err, c.App.AsymmetricSigningKey())
|
||||
}
|
||||
|
||||
if c.App.Metrics != nil {
|
||||
c.App.Metrics.IncrementHttpError()
|
||||
if c.App.Metrics() != nil {
|
||||
c.App.Metrics().IncrementHttpError()
|
||||
}
|
||||
}
|
||||
|
||||
if c.App.Metrics != nil {
|
||||
c.App.Metrics.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)
|
||||
c.App.Metrics.ObserveHttpRequestDuration(elapsed)
|
||||
c.App.Metrics.ObserveApiEndpointDuration(h.HandlerName, r.Method, elapsed)
|
||||
c.App.Metrics().ObserveHttpRequestDuration(elapsed)
|
||||
c.App.Metrics().ObserveApiEndpointDuration(h.HandlerName, r.Method, elapsed)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,7 +269,7 @@ func (h *Handler) checkCSRFToken(c *Context, r *http.Request, token string, toke
|
||||
}
|
||||
|
||||
if !csrfCheckPassed {
|
||||
c.App.Session = model.Session{}
|
||||
c.App.SetSession(&model.Session{})
|
||||
c.Err = model.NewAppError("ServeHTTP", "api.context.session_expired.app_error", nil, "token="+token+" Appears to be a CSRF attempt", http.StatusUnauthorized)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ func TestCheckCSRFToken(t *testing.T) {
|
||||
|
||||
c := &Context{
|
||||
App: th.App,
|
||||
Log: th.App.Log,
|
||||
Log: th.App.Log(),
|
||||
}
|
||||
r, _ := http.NewRequest(http.MethodPost, "", nil)
|
||||
r.Header.Set(model.HEADER_REQUESTED_WITH, model.HEADER_REQUESTED_WITH_XML)
|
||||
@@ -457,7 +457,7 @@ func TestCheckCSRFToken(t *testing.T) {
|
||||
|
||||
c := &Context{
|
||||
App: th.App,
|
||||
Log: th.App.Log,
|
||||
Log: th.App.Log(),
|
||||
}
|
||||
r, _ := http.NewRequest(http.MethodPost, "", nil)
|
||||
r.Header.Set(model.HEADER_REQUESTED_WITH, model.HEADER_REQUESTED_WITH_XML)
|
||||
|
||||
12
web/oauth.go
12
web/oauth.go
@@ -51,7 +51,7 @@ func authorizeOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.Session.IsOAuth {
|
||||
if c.App.Session().IsOAuth {
|
||||
c.SetPermissionError(model.PERMISSION_EDIT_OTHER_USERS)
|
||||
c.Err.DetailedError += ", attempted access by oauth app"
|
||||
return
|
||||
@@ -59,7 +59,7 @@ func authorizeOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
c.LogAudit("attempt")
|
||||
|
||||
redirectUrl, err := c.App.AllowOAuthAppAccessToUser(c.App.Session.UserId, authRequest)
|
||||
redirectUrl, err := c.App.AllowOAuthAppAccessToUser(c.App.Session().UserId, authRequest)
|
||||
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
@@ -80,7 +80,7 @@ func deauthorizeOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
err := c.App.DeauthorizeOAuthAppForUser(c.App.Session.UserId, clientId)
|
||||
err := c.App.DeauthorizeOAuthAppForUser(c.App.Session().UserId, clientId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -119,7 +119,7 @@ func authorizeOAuthPage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// here we should check if the user is logged in
|
||||
if len(c.App.Session.UserId) == 0 {
|
||||
if len(c.App.Session().UserId) == 0 {
|
||||
if loginHint == model.USER_AUTH_SERVICE_SAML {
|
||||
http.Redirect(w, r, c.GetSiteURLHeader()+"/login/sso/saml?redirect_to="+url.QueryEscape(r.RequestURI), http.StatusFound)
|
||||
} else {
|
||||
@@ -136,14 +136,14 @@ func authorizeOAuthPage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
isAuthorized := false
|
||||
|
||||
if _, err := c.App.GetPreferenceByCategoryAndNameForUser(c.App.Session.UserId, model.PREFERENCE_CATEGORY_AUTHORIZED_OAUTH_APP, authRequest.ClientId); err == nil {
|
||||
if _, err := c.App.GetPreferenceByCategoryAndNameForUser(c.App.Session().UserId, model.PREFERENCE_CATEGORY_AUTHORIZED_OAUTH_APP, authRequest.ClientId); err == nil {
|
||||
// when we support scopes we should check if the scopes match
|
||||
isAuthorized = true
|
||||
}
|
||||
|
||||
// Automatically allow if the app is trusted
|
||||
if oauthApp.IsTrusted || isAuthorized {
|
||||
redirectUrl, err := c.App.AllowOAuthAppAccessToUser(c.App.Session.UserId, authRequest)
|
||||
redirectUrl, err := c.App.AllowOAuthAppAccessToUser(c.App.Session().UserId, authRequest)
|
||||
|
||||
if err != nil {
|
||||
utils.RenderWebAppError(c.App.Config(), w, r, err, c.App.AsymmetricSigningKey())
|
||||
|
||||
@@ -336,7 +336,7 @@ func TestOAuthAccessToken(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
authData := &model.AuthData{ClientId: oauthApp.Id, RedirectUri: oauthApp.CallbackUrls[0], UserId: th.BasicUser.Id, Code: model.NewId(), ExpiresIn: -1}
|
||||
_, err = th.App.Srv.Store.OAuth().SaveAuthData(authData)
|
||||
_, err = th.App.Srv().Store.OAuth().SaveAuthData(authData)
|
||||
require.Nil(t, err)
|
||||
|
||||
data.Set("grant_type", model.ACCESS_TOKEN_GRANT_TYPE)
|
||||
@@ -473,7 +473,7 @@ func TestOAuthComplete(t *testing.T) {
|
||||
closeBody(r)
|
||||
}
|
||||
|
||||
_, err = th.App.Srv.Store.User().UpdateAuthData(
|
||||
_, err = th.App.Srv().Store.User().UpdateAuthData(
|
||||
th.BasicUser.Id, model.SERVICE_GITLAB, &th.BasicUser.Email, th.BasicUser.Email, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ func (w *Web) InitSaml() {
|
||||
}
|
||||
|
||||
func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
samlInterface := c.App.Saml
|
||||
samlInterface := c.App.Saml()
|
||||
|
||||
if samlInterface == nil {
|
||||
c.Err = model.NewAppError("loginWithSaml", "api.user.saml.not_available.app_error", nil, "", http.StatusFound)
|
||||
@@ -61,7 +61,7 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
samlInterface := c.App.Saml
|
||||
samlInterface := c.App.Saml()
|
||||
|
||||
if samlInterface == nil {
|
||||
c.Err = model.NewAppError("completeSaml", "api.user.saml.not_available.app_error", nil, "", http.StatusFound)
|
||||
@@ -111,7 +111,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
case model.OAUTH_ACTION_SIGNUP:
|
||||
teamId := relayProps["team_id"]
|
||||
if len(teamId) > 0 {
|
||||
c.App.Srv.Go(func() {
|
||||
c.App.Srv().Go(func() {
|
||||
if err = c.App.AddUserToTeamByTeamId(teamId, user); err != nil {
|
||||
mlog.Error(err.Error())
|
||||
} else {
|
||||
@@ -125,7 +125,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
c.LogAuditWithUserId(user.Id, "Revoked all sessions for user")
|
||||
c.App.Srv.Go(func() {
|
||||
c.App.Srv().Go(func() {
|
||||
if err = c.App.SendSignInChangeEmail(user.Email, strings.Title(model.USER_AUTH_SERVICE_SAML)+" SSO", user.Locale, c.App.GetSiteURL()); err != nil {
|
||||
mlog.Error(err.Error())
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ type SystemBrowser struct {
|
||||
MakeDefaultString string
|
||||
}
|
||||
|
||||
func renderUnsupportedBrowser(app *app.App, w http.ResponseWriter, r *http.Request) {
|
||||
func renderUnsupportedBrowser(app app.AppIface, w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
page := utils.NewHTMLTemplate(app.HTMLTemplates(), "unsupported_browser")
|
||||
|
||||
@@ -88,7 +88,7 @@ func renderUnsupportedBrowser(app *app.App, w http.ResponseWriter, r *http.Reque
|
||||
page.RenderToWriter(w)
|
||||
}
|
||||
|
||||
func renderMattermostAppMac(app *app.App) MattermostApp {
|
||||
func renderMattermostAppMac(app app.AppIface) MattermostApp {
|
||||
return MattermostApp{
|
||||
"/static/images/browser-icons/mac.png",
|
||||
app.T("web.error.unsupported_browser.download_the_app"),
|
||||
@@ -100,7 +100,7 @@ func renderMattermostAppMac(app *app.App) MattermostApp {
|
||||
}
|
||||
}
|
||||
|
||||
func renderMattermostAppWindows(app *app.App) MattermostApp {
|
||||
func renderMattermostAppWindows(app app.AppIface) MattermostApp {
|
||||
return MattermostApp{
|
||||
"/static/images/browser-icons/windows.svg",
|
||||
app.T("web.error.unsupported_browser.download_the_app"),
|
||||
@@ -112,7 +112,7 @@ func renderMattermostAppWindows(app *app.App) MattermostApp {
|
||||
}
|
||||
}
|
||||
|
||||
func renderBrowserChrome(app *app.App) Browser {
|
||||
func renderBrowserChrome(app app.AppIface) Browser {
|
||||
return Browser{
|
||||
"/static/images/browser-icons/chrome.svg",
|
||||
app.T("web.error.unsupported_browser.browser_title.chrome"),
|
||||
@@ -122,7 +122,7 @@ func renderBrowserChrome(app *app.App) Browser {
|
||||
}
|
||||
}
|
||||
|
||||
func renderBrowserFirefox(app *app.App) Browser {
|
||||
func renderBrowserFirefox(app app.AppIface) Browser {
|
||||
return Browser{
|
||||
"/static/images/browser-icons/firefox.svg",
|
||||
app.T("web.error.unsupported_browser.browser_title.firefox"),
|
||||
@@ -132,7 +132,7 @@ func renderBrowserFirefox(app *app.App) Browser {
|
||||
}
|
||||
}
|
||||
|
||||
func renderBrowserSafari(app *app.App) Browser {
|
||||
func renderBrowserSafari(app app.AppIface) Browser {
|
||||
return Browser{
|
||||
"/static/images/browser-icons/safari.svg",
|
||||
app.T("web.error.unsupported_browser.browser_title.safari"),
|
||||
@@ -142,7 +142,7 @@ func renderBrowserSafari(app *app.App) Browser {
|
||||
}
|
||||
}
|
||||
|
||||
func renderSystemBrowserEdge(app *app.App, r *http.Request) SystemBrowser {
|
||||
func renderSystemBrowserEdge(app app.AppIface, r *http.Request) SystemBrowser {
|
||||
return SystemBrowser{
|
||||
"/static/images/browser-icons/edge.svg",
|
||||
app.T("web.error.unsupported_browser.browser_title.edge"),
|
||||
|
||||
@@ -82,7 +82,7 @@ func IsApiCall(config configservice.ConfigService, r *http.Request) bool {
|
||||
return strings.HasPrefix(r.URL.Path, path.Join(subpath, "api")+"/")
|
||||
}
|
||||
|
||||
func IsWebhookCall(a *app.App, r *http.Request) bool {
|
||||
func IsWebhookCall(a app.AppIface, r *http.Request) bool {
|
||||
subpath, _ := utils.GetSubpathFromConfig(a.Config())
|
||||
|
||||
return strings.HasPrefix(r.URL.Path, path.Join(subpath, "hooks")+"/")
|
||||
|
||||
@@ -26,7 +26,7 @@ var ApiClient *model.Client4
|
||||
var URL string
|
||||
|
||||
type TestHelper struct {
|
||||
App *app.App
|
||||
App app.AppIface
|
||||
Server *app.Server
|
||||
Web *Web
|
||||
|
||||
@@ -75,12 +75,12 @@ func Setup(tb testing.TB) *TestHelper {
|
||||
})
|
||||
|
||||
web := New(s, s.AppOptions, s.Router)
|
||||
URL = fmt.Sprintf("http://localhost:%v", a.Srv.ListenAddr.Port)
|
||||
URL = fmt.Sprintf("http://localhost:%v", a.Srv().ListenAddr.Port)
|
||||
ApiClient = model.NewAPIv4Client(URL)
|
||||
|
||||
a.DoAppMigrations()
|
||||
|
||||
a.Srv.Store.MarkSystemRanUnitTests()
|
||||
a.Srv().Store.MarkSystemRanUnitTests()
|
||||
|
||||
a.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.TeamSettings.EnableOpenServer = true
|
||||
@@ -226,7 +226,7 @@ func TestPublicFilesRequest(t *testing.T) {
|
||||
defer os.RemoveAll(pluginDir)
|
||||
defer os.RemoveAll(webappPluginDir)
|
||||
|
||||
env, err := plugin.NewEnvironment(th.App.NewPluginAPI, pluginDir, webappPluginDir, th.App.Log)
|
||||
env, err := plugin.NewEnvironment(th.App.NewPluginAPI, pluginDir, webappPluginDir, th.App.Log())
|
||||
require.NoError(t, err)
|
||||
|
||||
pluginID := "com.mattermost.sample"
|
||||
|
||||
@@ -33,7 +33,7 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
defer func() {
|
||||
if *c.App.Config().LogSettings.EnableWebhookDebugging {
|
||||
if c.Err != nil {
|
||||
mlog.Debug("Incoming webhook received", mlog.String("webhook_id", id), mlog.String("request_id", c.App.RequestId), mlog.String("payload", incomingWebhookPayload.ToJson()))
|
||||
mlog.Debug("Incoming webhook received", mlog.String("webhook_id", id), mlog.String("request_id", c.App.RequestId()), mlog.String("payload", incomingWebhookPayload.ToJson()))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
Ссылка в новой задаче
Block a user