summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/slackimport.go26
-rw-r--r--i18n/en.json4
-rw-r--r--webapp/components/team_import_tab.jsx2
-rw-r--r--webapp/i18n/en.json2
4 files changed, 32 insertions, 2 deletions
diff --git a/api/slackimport.go b/api/slackimport.go
index df43e1a8b..4382e7f6d 100644
--- a/api/slackimport.go
+++ b/api/slackimport.go
@@ -12,6 +12,7 @@ import (
"github.com/mattermost/platform/utils"
"io"
"mime/multipart"
+ "regexp"
"strconv"
"strings"
)
@@ -230,6 +231,29 @@ func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[str
return addedChannels
}
+func SlackConvertUserMentions(users []SlackUser, posts map[string][]SlackPost) map[string][]SlackPost {
+ var regexes = make(map[string]*regexp.Regexp, len(users))
+ for _, user := range users {
+ r, err := regexp.Compile("<@" + user.Id + `(\|` + user.Username + ")?>")
+ if err != nil {
+ l4g.Warn(utils.T("api.slackimport.slack_convert_user_mentions.compile_regexp_failed.warn"), user.Id, user.Username)
+ continue
+ }
+ regexes["@"+user.Username] = r
+ }
+
+ for channelName, channelPosts := range posts {
+ for postIdx, post := range channelPosts {
+ for mention, r := range regexes {
+ post.Text = r.ReplaceAllString(post.Text, mention)
+ posts[channelName][postIdx] = post
+ }
+ }
+ }
+
+ return posts
+}
+
func SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model.AppError, *bytes.Buffer) {
zipreader, err := zip.NewReader(fileData, fileSize)
if err != nil || zipreader.File == nil {
@@ -266,6 +290,8 @@ func SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model
}
}
+ posts = SlackConvertUserMentions(users, posts)
+
addedUsers := SlackAddUsers(teamID, users, log)
SlackAddChannels(teamID, channels, posts, addedUsers, log)
diff --git a/i18n/en.json b/i18n/en.json
index 2f496d92b..0f1e4e215 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1420,6 +1420,10 @@
"translation": "Bad timestamp detected"
},
{
+ "id": "api.slackimport.slack_convert_user_mentions.compile_regexp_failed.warn",
+ "translation": "Failed to compile the @mention matching regular expression for Slack user {{.UserID}} {{.Username}}"
+ },
+ {
"id": "api.slackimport.slack_import.log",
"translation": "Mattermost Slack Import Log\r\n"
},
diff --git a/webapp/components/team_import_tab.jsx b/webapp/components/team_import_tab.jsx
index f724a789a..49d7f7f1f 100644
--- a/webapp/components/team_import_tab.jsx
+++ b/webapp/components/team_import_tab.jsx
@@ -48,7 +48,7 @@ class TeamImportTab extends React.Component {
<div>
<FormattedHTMLMessage
id='team_import_tab.importHelp'
- defaultMessage="<p>To import a team from Slack go to Slack > Team Settings > Import/Export Data > Export > Start Export. Slack does not allow you to export files, images, private groups or direct messages stored in Slack. Therefore, Slack import to Mattermost only supports importing of text messages in your Slack team's public channels.</p><p>The Slack import to Mattermost is in 'Beta'. Slack bot posts do not yet import and Slack @mentions are not currently supported.</p>"
+ defaultMessage="<p>To import a team from Slack go to Slack > Team Settings > Import/Export Data > Export > Start Export. Slack does not allow you to export files, images, private groups or direct messages stored in Slack. Therefore, Slack import to Mattermost only supports importing of text messages in your Slack team's public channels.</p><p>The Slack import to Mattermost is in 'Beta'. Slack bot posts do not yet import.</p>"
/>
</div>
);
diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json
index f78083c2f..71a903b5b 100644
--- a/webapp/i18n/en.json
+++ b/webapp/i18n/en.json
@@ -1664,7 +1664,7 @@
"team_export_tab.unable": " Unable to export: {error}",
"team_import_tab.failure": " Import failure: ",
"team_import_tab.import": "Import",
- "team_import_tab.importHelp": "<p>To import a team from Slack go to Slack > Team Settings > Import/Export Data > Export > Start Export. Slack does not allow you to export files, images, private groups or direct messages stored in Slack. Therefore, Slack import to Mattermost only supports importing of text messages in your Slack team's public channels.</p><p>The Slack import to Mattermost is in 'Beta'. Slack bot posts do not yet import and Slack @mentions are not currently supported.</p>",
+ "team_import_tab.importHelp": "<p>To import a team from Slack go to Slack > Team Settings > Import/Export Data > Export > Start Export. Slack does not allow you to export files, images, private groups or direct messages stored in Slack. Therefore, Slack import to Mattermost only supports importing of text messages in your Slack team's public channels.</p><p>The Slack import to Mattermost is in 'Beta'. Slack bot posts do not yet import.</p>",
"team_import_tab.importSlack": "Import from Slack (Beta)",
"team_import_tab.importing": " Importing...",
"team_import_tab.successful": " Import successful: ",