diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-09-13 11:56:03 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-09-13 11:56:03 -0400 |
commit | 132be6a02b125bb2458e918272d61d23fa1d5ab1 (patch) | |
tree | 4d18873d404089e4814c09f0cd69b1890e327c51 /api | |
parent | cdeb9f56b733ae697fe3e9baa852847d500ab684 (diff) | |
download | chat-132be6a02b125bb2458e918272d61d23fa1d5ab1.tar.gz chat-132be6a02b125bb2458e918272d61d23fa1d5ab1.tar.bz2 chat-132be6a02b125bb2458e918272d61d23fa1d5ab1.zip |
Accept nil values for incoming webhook attachments (#4011)
Diffstat (limited to 'api')
-rw-r--r-- | api/post.go | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/api/post.go b/api/post.go index b046c182b..9a11a5c59 100644 --- a/api/post.go +++ b/api/post.go @@ -195,14 +195,12 @@ func CreateWebhookPost(c *Context, channelId, text, overrideUsername, overrideIc // parse attachment links into Markdown format for i, aInt := range list { attachment := aInt.(map[string]interface{}) - if _, ok := attachment["text"]; ok { - aText := attachment["text"].(string) + if aText, ok := attachment["text"].(string); ok { aText = linkWithTextRegex.ReplaceAllString(aText, "[${2}](${1})") attachment["text"] = aText list[i] = attachment } - if _, ok := attachment["pretext"]; ok { - aText := attachment["pretext"].(string) + if aText, ok := attachment["pretext"].(string); ok { aText = linkWithTextRegex.ReplaceAllString(aText, "[${2}](${1})") attachment["pretext"] = aText list[i] = attachment @@ -212,8 +210,7 @@ func CreateWebhookPost(c *Context, channelId, text, overrideUsername, overrideIc // parse attachment field links into Markdown format for j, fInt := range fields { field := fInt.(map[string]interface{}) - if _, ok := field["value"]; ok { - fValue := field["value"].(string) + if fValue, ok := field["value"].(string); ok { fValue = linkWithTextRegex.ReplaceAllString(fValue, "[${2}](${1})") field["value"] = fValue fields[j] = field |