diff options
author | thoemy <thoemy@gmx.net> | 2016-05-12 13:44:44 +0200 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-05-12 12:04:59 -0400 |
commit | 04dfa2a9eb50d60b2d4c2533f465799966b363a6 (patch) | |
tree | 56b1b8288b928b99eddf5994d20c965a65c108f8 /api | |
parent | 97450762dbb8323756d0f52cc7b59b86d0319b97 (diff) | |
download | chat-04dfa2a9eb50d60b2d4c2533f465799966b363a6.tar.gz chat-04dfa2a9eb50d60b2d4c2533f465799966b363a6.tar.bz2 chat-04dfa2a9eb50d60b2d4c2533f465799966b363a6.zip |
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.
Diffstat (limited to 'api')
-rw-r--r-- | api/webhook.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/api/webhook.go b/api/webhook.go index ea628e39c..a4367026f 100644 --- a/api/webhook.go +++ b/api/webhook.go @@ -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 { |