summaryrefslogtreecommitdiffstats
path: root/api/post.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-01-21 07:07:28 -0500
committerJoram Wilander <jwawilander@gmail.com>2016-01-21 07:07:28 -0500
commitdd0f49e5ffd978513188ec768eb3a06c9b25888b (patch)
tree818af5586f51ac65aa3034e3e7c41767530ddb0c /api/post.go
parent9f526555df64885be27e38e588c23332d80cd208 (diff)
parentb0fcdd1b4cfb90e8e728ae19b0081d93cdf51257 (diff)
downloadchat-dd0f49e5ffd978513188ec768eb3a06c9b25888b.tar.gz
chat-dd0f49e5ffd978513188ec768eb3a06c9b25888b.tar.bz2
chat-dd0f49e5ffd978513188ec768eb3a06c9b25888b.zip
Merge pull request #1867 from apskim/patch-1
Parse Slack links in the attachment pretext and fields (Fix #1868)
Diffstat (limited to 'api/post.go')
-rw-r--r--api/post.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/api/post.go b/api/post.go
index 7cd45d310..42c3c304d 100644
--- a/api/post.go
+++ b/api/post.go
@@ -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)
}