Fix parsing attachment field links into markdown (#2958) (#2959)

Field contents are stored in 'value' not 'text'.
This commit is contained in:
thoemy
2016-05-12 14:30:44 +02:00
committed by Christopher Speller
parent 4b260b761a
commit 3f0325fd22
2 changed files with 9 additions and 4 deletions

View File

@@ -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
}
}

View File

@@ -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": [