diff options
-rw-r--r-- | api/slackimport.go | 32 | ||||
-rw-r--r-- | i18n/en.json | 4 |
2 files changed, 24 insertions, 12 deletions
diff --git a/api/slackimport.go b/api/slackimport.go index 27b8e7f5d..a374d335b 100644 --- a/api/slackimport.go +++ b/api/slackimport.go @@ -31,14 +31,19 @@ type SlackUser 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 map[string]string `json:"comment"` + 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"` +} + +type SlackComment struct { + User string `json:"user"` + Comment string `json:"comment"` } func SlackConvertTimeStamp(ts string) int64 { @@ -172,17 +177,20 @@ func SlackAddPosts(channel *model.Channel, posts []SlackPost, users map[string]* } ImportPost(&newPost) case sPost.Type == "message" && sPost.SubType == "file_comment": - if sPost.Comment["user"] == "" { + if sPost.Comment == nil { + l4g.Debug(utils.T("api.slackimport.slack_add_posts.msg_no_comment.debug")) + continue + } else if sPost.Comment.User == "" { l4g.Debug(utils.T("api.slackimport.slack_add_posts.msg_no_usr.debug")) continue - } else if users[sPost.Comment["user"]] == nil { + } else if users[sPost.Comment.User] == nil { l4g.Debug(utils.T("api.slackimport.slack_add_posts.user_no_exists.debug"), sPost.User) continue } newPost := model.Post{ - UserId: users[sPost.Comment["user"]].Id, + UserId: users[sPost.Comment.User].Id, ChannelId: channel.Id, - Message: sPost.Comment["comment"], + Message: sPost.Comment.Comment, CreateAt: SlackConvertTimeStamp(sPost.TimeStamp), } ImportPost(&newPost) diff --git a/i18n/en.json b/i18n/en.json index 7362d5ce7..2b5a1e095 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -1548,6 +1548,10 @@ "translation": "Slack bot posts are not imported yet" }, { + "id": "api.slackimport.slack_add_posts.msg_no_comment.debug", + "translation": "File comment message without comment" + }, + { "id": "api.slackimport.slack_add_posts.msg_no_usr.debug", "translation": "Message without user" }, |