summaryrefslogtreecommitdiffstats
path: root/web/web.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-10-26 15:10:17 -0400
committerJoramWilander <jwawilander@gmail.com>2015-10-26 15:10:17 -0400
commitc94388042b684ae3c552f97505fdb67903db20ba (patch)
treedbf42978b7de9fa2db4f9c5c4058df024ecaebeb /web/web.go
parent2680b81568ca3f8eac1d5937f85085f1785eb84d (diff)
downloadchat-c94388042b684ae3c552f97505fdb67903db20ba.tar.gz
chat-c94388042b684ae3c552f97505fdb67903db20ba.tar.bz2
chat-c94388042b684ae3c552f97505fdb67903db20ba.zip
Parse incoming webhook requsets into model instead of string map
Diffstat (limited to 'web/web.go')
-rw-r--r--web/web.go14
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)