diff options
author | thoemy <thoemy@gmx.net> | 2016-05-12 14:30:44 +0200 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-05-12 12:04:12 -0400 |
commit | 97450762dbb8323756d0f52cc7b59b86d0319b97 (patch) | |
tree | 51706e6b866d8fc86d4702091ab4fd687f672c04 | |
parent | d9f724f959e86e417e274f50b249b39acaf81a79 (diff) | |
download | chat-97450762dbb8323756d0f52cc7b59b86d0319b97.tar.gz chat-97450762dbb8323756d0f52cc7b59b86d0319b97.tar.bz2 chat-97450762dbb8323756d0f52cc7b59b86d0319b97.zip |
Fix parsing attachment field links into markdown (#2958) (#2959)
Field contents are stored in 'value' not 'text'.
-rw-r--r-- | api/post.go | 8 | ||||
-rw-r--r-- | tests/test-slack-attachments.json | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/api/post.go b/api/post.go index ac499e615..734cb7148 100644 --- a/api/post.go +++ b/api/post.go @@ -200,10 +200,10 @@ 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["text"]; ok { - fText := field["text"].(string) - fText = linkWithTextRegex.ReplaceAllString(fText, "[${2}](${1})") - field["text"] = fText + if _, ok := field["value"]; ok { + fValue := field["value"].(string) + fValue = linkWithTextRegex.ReplaceAllString(fValue, "[${2}](${1})") + field["value"] = fValue fields[j] = field } } diff --git a/tests/test-slack-attachments.json b/tests/test-slack-attachments.json index 1c499b4ca..3787eb143 100644 --- a/tests/test-slack-attachments.json +++ b/tests/test-slack-attachments.json @@ -39,6 +39,11 @@ "short": true, "title": "Short 2", "value": "Another one" + }, + { + "short": true, + "title": "Field with link", + "value": "<http://example.com|Link>" } ], "mrkdwn_in": [ |