diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2017-03-10 05:22:14 -0500 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-03-10 10:22:14 +0000 |
commit | 06a7c3ba8e054237c44e8b1586c76d00c1cffb67 (patch) | |
tree | 396ae2313e89bef2c8c8de4ac0fc3d3273f0077d /app/slackimport.go | |
parent | 06930f378cd61c72f0ba9b0718bc54eea0c30406 (diff) | |
download | chat-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/slackimport.go')
-rw-r--r-- | app/slackimport.go | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/app/slackimport.go b/app/slackimport.go index ced0f6581..fcdd765bb 100644 --- a/app/slackimport.go +++ b/app/slackimport.go @@ -40,17 +40,17 @@ type SlackFile struct { } type SlackPost struct { - User string `json:"user"` - BotId string `json:"bot_id"` - BotUsername string `json:"username"` - Text string `json:"text"` - TimeStamp string `json:"ts"` - Type string `json:"type"` - SubType string `json:"subtype"` - Comment *SlackComment `json:"comment"` - Upload bool `json:"upload"` - File *SlackFile `json:"file"` - Attachments []SlackAttachment `json:"attachments"` + User string `json:"user"` + BotId string `json:"bot_id"` + BotUsername string `json:"username"` + Text string `json:"text"` + TimeStamp string `json:"ts"` + Type string `json:"type"` + SubType string `json:"subtype"` + Comment *SlackComment `json:"comment"` + Upload bool `json:"upload"` + File *SlackFile `json:"file"` + Attachments []*model.SlackAttachment `json:"attachments"` } type SlackComment struct { @@ -58,13 +58,6 @@ type SlackComment struct { Comment string `json:"comment"` } -type SlackAttachment struct { - Id int `json:"id"` - Text string `json:"text"` - Pretext string `json:"pretext"` - Fields []map[string]interface{} `json:"fields"` -} - func truncateRunes(s string, i int) string { runes := []rune(s) if len(runes) > i { @@ -284,15 +277,7 @@ func SlackAddPosts(teamId string, channel *model.Channel, posts []SlackPost, use props := make(model.StringInterface) props["override_username"] = sPost.BotUsername if len(sPost.Attachments) > 0 { - var mAttachments []interface{} - for _, attachment := range sPost.Attachments { - mAttachments = append(mAttachments, map[string]interface{}{ - "text": attachment.Text, - "pretext": attachment.Pretext, - "fields": attachment.Fields, - }) - } - props["attachments"] = mAttachments + props["attachments"] = sPost.Attachments } post := &model.Post{ |