From 8cf4a8d2d7650204384293106d47468edf09eb91 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Wed, 18 Jan 2017 20:47:32 +0000 Subject: PLT-4845: Slack import of channel purpose changed messages. (#5110) Also includes channel header changed messages and channel name changed messages. --- api/slackimport.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/api/slackimport.go b/api/slackimport.go index 2db1b44f0..9d432b987 100644 --- a/api/slackimport.go +++ b/api/slackimport.go @@ -331,6 +331,54 @@ func SlackAddPosts(teamId string, channel *model.Channel, posts []SlackPost, use CreateAt: SlackConvertTimeStamp(sPost.TimeStamp), } ImportPost(&newPost) + case sPost.Type == "message" && sPost.SubType == "channel_topic": + if sPost.User == "" { + l4g.Debug(utils.T("api.slackimport.slack_add_posts.msg_no_usr.debug")) + continue + } else if users[sPost.User] == nil { + l4g.Debug(utils.T("api.slackimport.slack_add_posts.user_no_exists.debug"), sPost.User) + continue + } + newPost := model.Post{ + UserId: users[sPost.User].Id, + ChannelId: channel.Id, + Message: sPost.Text, + CreateAt: SlackConvertTimeStamp(sPost.TimeStamp), + Type: model.POST_HEADER_CHANGE, + } + ImportPost(&newPost) + case sPost.Type == "message" && sPost.SubType == "channel_purpose": + if sPost.User == "" { + l4g.Debug(utils.T("api.slackimport.slack_add_posts.msg_no_usr.debug")) + continue + } else if users[sPost.User] == nil { + l4g.Debug(utils.T("api.slackimport.slack_add_posts.user_no_exists.debug"), sPost.User) + continue + } + newPost := model.Post{ + UserId: users[sPost.User].Id, + ChannelId: channel.Id, + Message: sPost.Text, + CreateAt: SlackConvertTimeStamp(sPost.TimeStamp), + Type: model.POST_PURPOSE_CHANGE, + } + ImportPost(&newPost) + case sPost.Type == "message" && sPost.SubType == "channel_name": + if sPost.User == "" { + l4g.Debug(utils.T("api.slackimport.slack_add_posts.msg_no_usr.debug")) + continue + } else if users[sPost.User] == nil { + l4g.Debug(utils.T("api.slackimport.slack_add_posts.user_no_exists.debug"), sPost.User) + continue + } + newPost := model.Post{ + UserId: users[sPost.User].Id, + ChannelId: channel.Id, + Message: sPost.Text, + CreateAt: SlackConvertTimeStamp(sPost.TimeStamp), + Type: model.POST_DISPLAYNAME_CHANGE, + } + ImportPost(&newPost) default: l4g.Warn(utils.T("api.slackimport.slack_add_posts.unsupported.warn"), sPost.Type, sPost.SubType) } -- cgit v1.2.3-1-g7c22