summaryrefslogtreecommitdiffstats
path: root/app/import.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-03-10 05:22:14 -0500
committerGeorge Goldberg <george@gberg.me>2017-03-10 10:22:14 +0000
commit06a7c3ba8e054237c44e8b1586c76d00c1cffb67 (patch)
tree396ae2313e89bef2c8c8de4ac0fc3d3273f0077d /app/import.go
parent06930f378cd61c72f0ba9b0718bc54eea0c30406 (diff)
downloadchat-06a7c3ba8e054237c44e8b1586c76d00c1cffb67.tar.gz
chat-06a7c3ba8e054237c44e8b1586c76d00c1cffb67.tar.bz2
chat-06a7c3ba8e054237c44e8b1586c76d00c1cffb67.zip
PLT-5800 Cleaned up duplicated code for adding slack attachments to posts (#5711)
Diffstat (limited to 'app/import.go')
-rw-r--r--app/import.go33
1 files changed, 2 insertions, 31 deletions
diff --git a/app/import.go b/app/import.go
index 4d0feb532..a5ed69843 100644
--- a/app/import.go
+++ b/app/import.go
@@ -915,37 +915,8 @@ func OldImportIncomingWebhookPost(post *model.Post, props model.StringInterface)
if len(props) > 0 {
for key, val := range props {
if key == "attachments" {
- if list, success := val.([]interface{}); success {
- // parse attachment links into Markdown format
- for i, aInt := range list {
- attachment := aInt.(map[string]interface{})
- if aText, ok := attachment["text"].(string); ok {
- aText = linkWithTextRegex.ReplaceAllString(aText, "[${2}](${1})")
- attachment["text"] = aText
- list[i] = attachment
- }
- if aText, ok := attachment["pretext"].(string); ok {
- 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 fValue, ok := field["value"].(string); ok {
- fValue = linkWithTextRegex.ReplaceAllString(fValue, "[${2}](${1})")
- field["value"] = fValue
- fields[j] = field
- }
- }
- attachment["fields"] = fields
- list[i] = attachment
- }
- }
- }
- post.AddProp(key, list)
+ if attachments, success := val.([]*model.SlackAttachment); success {
+ parseSlackAttachment(post, attachments)
}
} else if key != "from_webhook" {
post.AddProp(key, val)