Merge pull request #1867 from apskim/patch-1

Parse Slack links in the attachment pretext and fields (Fix #1868)
Этот коммит содержится в:
Joram Wilander
2016-01-21 07:07:28 -05:00
родитель 9f526555df b0fcdd1b4c
Коммит dd0f49e5ff

Просмотреть файл

@@ -185,6 +185,28 @@ func CreateWebhookPost(c *Context, channelId, text, overrideUsername, overrideIc
attachment["text"] = aText
list[i] = attachment
}
if _, ok := attachment["pretext"]; ok {
aText := attachment["pretext"].(string)
aText = linkWithTextRegex.ReplaceAllString(aText, "[${2}](${1})")
attachment["pretext"] = aText
list[i] = attachment
}
if fVal, ok := attachment["fields"]; ok {
if fields, ok := fVal.([]interface{}); ok {
// 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
fields[j] = field
}
}
attachment["fields"] = fields
list[i] = attachment
}
}
}
post.AddProp(key, list)
}