diff options
author | Corey Hulen <corey@hulen.com> | 2015-10-26 22:06:49 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-10-26 22:06:49 -0700 |
commit | 28847c6b4b864d747bbfdf5c53354dcb24e5f895 (patch) | |
tree | a429200e3ddde63e7ba6fd90c49303c58a204ce9 /web/web.go | |
parent | 2b198a8cfc6733049d26bcb73c3f443afcea9e82 (diff) | |
parent | 12399dd43c0ba57a879e4383f13a0fd4ed3350ae (diff) | |
download | chat-28847c6b4b864d747bbfdf5c53354dcb24e5f895.tar.gz chat-28847c6b4b864d747bbfdf5c53354dcb24e5f895.tar.bz2 chat-28847c6b4b864d747bbfdf5c53354dcb24e5f895.zip |
Merge pull request #1194 from mattermost/webhook-request
Parse incoming webhook requests into model instead of string map
Diffstat (limited to 'web/web.go')
-rw-r--r-- | web/web.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/web/web.go b/web/web.go index 5f290ec99..bffe4858e 100644 --- a/web/web.go +++ b/web/web.go @@ -969,20 +969,20 @@ func incomingWebhook(c *api.Context, w http.ResponseWriter, r *http.Request) { r.ParseForm() - var props map[string]string + var parsedRequest *model.IncomingWebhookRequest if r.Header.Get("Content-Type") == "application/json" { - props = model.MapFromJson(r.Body) + parsedRequest = model.IncomingWebhookRequestFromJson(r.Body) } else { - props = model.MapFromJson(strings.NewReader(r.FormValue("payload"))) + parsedRequest = model.IncomingWebhookRequestFromJson(strings.NewReader(r.FormValue("payload"))) } - text := props["text"] + text := parsedRequest.Text if len(text) == 0 { c.Err = model.NewAppError("incomingWebhook", "No text specified", "") return } - channelName := props["channel"] + channelName := parsedRequest.ChannelName var hook *model.IncomingWebhook if result := <-hchan; result.Err != nil { @@ -1012,8 +1012,8 @@ func incomingWebhook(c *api.Context, w http.ResponseWriter, r *http.Request) { cchan = api.Srv.Store.Channel().Get(hook.ChannelId) } - overrideUsername := props["username"] - overrideIconUrl := props["icon_url"] + overrideUsername := parsedRequest.Username + overrideIconUrl := parsedRequest.IconURL if result := <-cchan; result.Err != nil { c.Err = model.NewAppError("incomingWebhook", "Couldn't find the channel", "err="+result.Err.Message) |