summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2016-09-19 13:22:08 +0100
committerJoram Wilander <jwawilander@gmail.com>2016-09-19 08:22:08 -0400
commit33eda94db33417c839499b1b3e0330a4fdd1de19 (patch)
tree855accd0e1348bd7b496f1bc0cb235df059180d4 /api
parent8443ca58289055cde25a3cdaaa3987c6f8cfde4a (diff)
downloadchat-33eda94db33417c839499b1b3e0330a4fdd1de19.tar.gz
chat-33eda94db33417c839499b1b3e0330a4fdd1de19.tar.bz2
chat-33eda94db33417c839499b1b3e0330a4fdd1de19.zip
PLT-1764 #channels => !channels on Slack import. (#4028)
Diffstat (limited to 'api')
-rw-r--r--api/slackimport.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/api/slackimport.go b/api/slackimport.go
index 7790a21e3..cb6877616 100644
--- a/api/slackimport.go
+++ b/api/slackimport.go
@@ -285,6 +285,24 @@ func SlackConvertUserMentions(users []SlackUser, posts map[string][]SlackPost) m
return posts
}
+func SlackConvertChannelMentions(channels []SlackChannel, posts map[string][]SlackPost) map[string][]SlackPost {
+ var channelPatterns = make(map[string]string, len(channels))
+ for _, channel := range channels {
+ channelPatterns["!"+channel.Name] = "<#" + channel.Id + ">"
+ }
+
+ for channelName, channelPosts := range posts {
+ for postIdx, post := range channelPosts {
+ for channelReplace, channelMatch := range channelPatterns {
+ post.Text = strings.Replace(post.Text, channelMatch, channelReplace, -1)
+ posts[channelName][postIdx] = post
+ }
+ }
+ }
+
+ return posts
+}
+
func SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model.AppError, *bytes.Buffer) {
// Create log file
log := bytes.NewBufferString(utils.T("api.slackimport.slack_import.log"))
@@ -324,6 +342,7 @@ func SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model
}
posts = SlackConvertUserMentions(users, posts)
+ posts = SlackConvertChannelMentions(channels, posts)
addedUsers := SlackAddUsers(teamID, users, log)
SlackAddChannels(teamID, channels, posts, addedUsers, log)