[Fix #1669] Allow parameters in Content-Type of incoming webhook request
Mattermost currently does not allow optional parameters in the `Content-Type` of an incoming webhook request. Visual Studio Team Services's Slack integration sends its message with `Content-Type: application/json; charset=utf-8`, whereas Mattermost currently requires precisely `Content-Type: application/json`. This PR relaxes this check, looking only at the media part of the header.
Этот коммит содержится в:
коммит произвёл
Alex Polozov
родитель
482158d2bb
Коммит
23a8d954d9
@@ -1017,7 +1017,8 @@ func incomingWebhook(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
|
|
||||||
var parsedRequest *model.IncomingWebhookRequest
|
var parsedRequest *model.IncomingWebhookRequest
|
||||||
if r.Header.Get("Content-Type") == "application/json" {
|
contentType := r.Header.Get("Content-Type")
|
||||||
|
if strings.Split(contentType, "; ")[0] == "application/json" {
|
||||||
parsedRequest = model.IncomingWebhookRequestFromJson(r.Body)
|
parsedRequest = model.IncomingWebhookRequestFromJson(r.Body)
|
||||||
} else {
|
} else {
|
||||||
parsedRequest = model.IncomingWebhookRequestFromJson(strings.NewReader(r.FormValue("payload")))
|
parsedRequest = model.IncomingWebhookRequestFromJson(strings.NewReader(r.FormValue("payload")))
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user