summaryrefslogtreecommitdiffstats
path: root/api/post.go
diff options
context:
space:
mode:
authorAlex Polozov <apskim@users.noreply.github.com>2016-01-11 16:44:18 -0800
committerAlex Polozov <polozov@cs.washington.edu>2016-01-11 17:54:16 -0800
commitb0fcdd1b4cfb90e8e728ae19b0081d93cdf51257 (patch)
treecd9c6690fe428e9d4a17969031197edbd74a595b /api/post.go
parent1768d2c844063432aa901975b80d6ccf12df4add (diff)
downloadchat-b0fcdd1b4cfb90e8e728ae19b0081d93cdf51257.tar.gz
chat-b0fcdd1b4cfb90e8e728ae19b0081d93cdf51257.tar.bz2
chat-b0fcdd1b4cfb90e8e728ae19b0081d93cdf51257.zip
Parse Slack links in the attachment fields
Diffstat (limited to 'api/post.go')
-rw-r--r--api/post.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/api/post.go b/api/post.go
index fd0e37f29..1ca198d6f 100644
--- a/api/post.go
+++ b/api/post.go
@@ -191,6 +191,22 @@ func CreateWebhookPost(c *Context, channelId, text, overrideUsername, overrideIc
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)
}