mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Parse Slack links in the attachment fields
This commit is contained in:
committed by
Alex Polozov
parent
1768d2c844
commit
b0fcdd1b4c
16
api/post.go
16
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user