summaryrefslogtreecommitdiffstats
path: root/api/slackimport.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-09-14 12:04:57 -0400
committerChristopher Speller <crspeller@gmail.com>2015-09-14 12:18:38 -0400
commit7b3c2d6d85ecee86fbc85b440e7028018b1090b1 (patch)
tree2493b0f770c931cedde57f8d787f37f6631de484 /api/slackimport.go
parentb2378f433ecd44a9811a52bd58e36a40f92e193f (diff)
downloadchat-7b3c2d6d85ecee86fbc85b440e7028018b1090b1.tar.gz
chat-7b3c2d6d85ecee86fbc85b440e7028018b1090b1.tar.bz2
chat-7b3c2d6d85ecee86fbc85b440e7028018b1090b1.zip
Allowing underscores in channel names. Added conversion of some slack channel names into valid mattermost names.
Diffstat (limited to 'api/slackimport.go')
-rw-r--r--api/slackimport.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/api/slackimport.go b/api/slackimport.go
index 1d037a934..4e6c01dbb 100644
--- a/api/slackimport.go
+++ b/api/slackimport.go
@@ -50,6 +50,15 @@ func SlackConvertTimeStamp(ts string) int64 {
return timeStamp * 1000 // Convert to milliseconds
}
+func SlackConvertChannelName(channelName string) string {
+ newName := strings.Trim(channelName, "_-")
+ if len(newName) == 1 {
+ return "slack-channel-" + newName
+ }
+
+ return newName
+}
+
func SlackParseChannels(data io.Reader) []SlackChannel {
decoder := json.NewDecoder(data)
@@ -172,7 +181,7 @@ func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[str
TeamId: teamId,
Type: model.CHANNEL_OPEN,
DisplayName: sChannel.Name,
- Name: sChannel.Name,
+ Name: SlackConvertChannelName(sChannel.Name),
Description: sChannel.Topic["value"],
}
mChannel := ImportChannel(&newChannel)