Commit 04dfa2a9 authored by thoemy's avatar thoemy Committed by Christopher Speller
Browse files

Improve incoming webhook slack compatibility (#2972) (#2973)

By checking for form urlencoded content instead of JSON, requests without
or with a wrong Content-Type header and a JSON body are correctly parsed.
parent 97450762
......@@ -358,10 +358,10 @@ func incomingWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
var parsedRequest *model.IncomingWebhookRequest
contentType := r.Header.Get("Content-Type")
if strings.Split(contentType, "; ")[0] == "application/json" {
parsedRequest = model.IncomingWebhookRequestFromJson(r.Body)
} else {
if strings.Split(contentType, "; ")[0] == "application/x-www-form-urlencoded" {
parsedRequest = model.IncomingWebhookRequestFromJson(strings.NewReader(r.FormValue("payload")))
} else {
parsedRequest = model.IncomingWebhookRequestFromJson(r.Body)
}
if parsedRequest == nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment