summaryrefslogtreecommitdiffstats
path: root/api/webhook.go
diff options
context:
space:
mode:
authorthoemy <thoemy@gmx.net>2016-05-12 13:44:44 +0200
committerJoram Wilander <jwawilander@gmail.com>2016-05-12 07:44:44 -0400
commitb4adf776931c477b13a50fdc9ed0281ff72983b3 (patch)
tree594fc638117a6fff650b7df75497033bedb26be1 /api/webhook.go
parent2b1db2974a9bf0b801ba00c9a7c689cf92fe139d (diff)
downloadchat-b4adf776931c477b13a50fdc9ed0281ff72983b3.tar.gz
chat-b4adf776931c477b13a50fdc9ed0281ff72983b3.tar.bz2
chat-b4adf776931c477b13a50fdc9ed0281ff72983b3.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/webhook.go')
-rw-r--r--api/webhook.go6
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 {