Use request.CTX instead of *request.Context (#24877)
* Use request.CTX instead of *request.Context * Fix tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
37dc35c1a1
Коммит
c7461751f2
@@ -40,11 +40,11 @@ import (
|
||||
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
||||
)
|
||||
|
||||
func (a *App) DoPostAction(c *request.Context, postID, actionId, userID, selectedOption string) (string, *model.AppError) {
|
||||
func (a *App) DoPostAction(c request.CTX, postID, actionId, userID, selectedOption string) (string, *model.AppError) {
|
||||
return a.DoPostActionWithCookie(c, postID, actionId, userID, selectedOption, nil)
|
||||
}
|
||||
|
||||
func (a *App) DoPostActionWithCookie(c *request.Context, postID, actionId, userID, selectedOption string, cookie *model.PostActionCookie) (string, *model.AppError) {
|
||||
func (a *App) DoPostActionWithCookie(c request.CTX, postID, actionId, userID, selectedOption string, cookie *model.PostActionCookie) (string, *model.AppError) {
|
||||
// PostAction may result in the original post being updated. For the
|
||||
// updated post, we need to unconditionally preserve the original
|
||||
// IsPinned and HasReaction attributes, and preserve its entire
|
||||
@@ -309,7 +309,7 @@ func (a *App) DoPostActionWithCookie(c *request.Context, postID, actionId, userI
|
||||
// Perform an HTTP POST request to an integration's action endpoint.
|
||||
// Caller must consume and close returned http.Response as necessary.
|
||||
// For internal requests, requests are routed directly to a plugin ServerHTTP hook
|
||||
func (a *App) DoActionRequest(c *request.Context, rawURL string, body []byte) (*http.Response, *model.AppError) {
|
||||
func (a *App) DoActionRequest(c request.CTX, rawURL string, body []byte) (*http.Response, *model.AppError) {
|
||||
inURL, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("DoActionRequest", "api.post.do_action.action_integration.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
@@ -373,11 +373,11 @@ func (w *LocalResponseWriter) WriteHeader(statusCode int) {
|
||||
w.status = statusCode
|
||||
}
|
||||
|
||||
func (a *App) doPluginRequest(c *request.Context, method, rawURL string, values url.Values, body []byte) (*http.Response, *model.AppError) {
|
||||
func (a *App) doPluginRequest(c request.CTX, method, rawURL string, values url.Values, body []byte) (*http.Response, *model.AppError) {
|
||||
return a.ch.doPluginRequest(c, method, rawURL, values, body)
|
||||
}
|
||||
|
||||
func (ch *Channels) doPluginRequest(c *request.Context, method, rawURL string, values url.Values, body []byte) (*http.Response, *model.AppError) {
|
||||
func (ch *Channels) doPluginRequest(c request.CTX, method, rawURL string, values url.Values, body []byte) (*http.Response, *model.AppError) {
|
||||
rawURL = strings.TrimPrefix(rawURL, "/")
|
||||
inURL, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
@@ -443,7 +443,7 @@ func (ch *Channels) doPluginRequest(c *request.Context, method, rawURL string, v
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (a *App) doLocalWarnMetricsRequest(c *request.Context, rawURL string, upstreamRequest *model.PostActionIntegrationRequest) *model.AppError {
|
||||
func (a *App) doLocalWarnMetricsRequest(c request.CTX, rawURL string, upstreamRequest *model.PostActionIntegrationRequest) *model.AppError {
|
||||
_, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
return model.NewAppError("doLocalWarnMetricsRequest", "api.post.do_action.action_integration.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
@@ -579,7 +579,7 @@ func (a *App) buildWarnMetricMailtoLink(rctx request.CTX, warnMetricId string, u
|
||||
return mailToLinkContent.ToJSON()
|
||||
}
|
||||
|
||||
func (a *App) DoLocalRequest(c *request.Context, rawURL string, body []byte) (*http.Response, *model.AppError) {
|
||||
func (a *App) DoLocalRequest(c request.CTX, rawURL string, body []byte) (*http.Response, *model.AppError) {
|
||||
return a.doPluginRequest(c, "POST", rawURL, nil, body)
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ func (a *App) OpenInteractiveDialog(request model.OpenDialogRequest) *model.AppE
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SubmitInteractiveDialog(c *request.Context, request model.SubmitDialogRequest) (*model.SubmitDialogResponse, *model.AppError) {
|
||||
func (a *App) SubmitInteractiveDialog(c request.CTX, request model.SubmitDialogRequest) (*model.SubmitDialogResponse, *model.AppError) {
|
||||
url := request.URL
|
||||
request.URL = ""
|
||||
request.Type = "dialog_submission"
|
||||
|
||||
Ссылка в новой задаче
Block a user