summaryrefslogtreecommitdiffstats
path: root/app/export.go
diff options
context:
space:
mode:
authorWasim Thabraze <wasim@thabraze.me>2018-10-17 18:53:10 +0530
committerGeorge Goldberg <george@gberg.me>2018-10-17 14:23:10 +0100
commit7562f940bb7b0de80bcfb8f5c3fc1b751a1a6b16 (patch)
tree19ce5b4d1031887ea62865006f8b7ead892d543c /app/export.go
parent1befeb61d0299028d050a732ea9c8f7e8774ed74 (diff)
downloadchat-7562f940bb7b0de80bcfb8f5c3fc1b751a1a6b16.tar.gz
chat-7562f940bb7b0de80bcfb8f5c3fc1b751a1a6b16.tar.bz2
chat-7562f940bb7b0de80bcfb8f5c3fc1b751a1a6b16.zip
[MM-12465] Added capability to export reactions of posts during bulk export (#9600)
* Added capability to export reactions of posts * Added capability to export reactions of replies of a post * Added test case to test the reactions of a post
Diffstat (limited to 'app/export.go')
-rw-r--r--app/export.go36
1 files changed, 35 insertions, 1 deletions
diff --git a/app/export.go b/app/export.go
index a7a78cfee..b911954a5 100644
--- a/app/export.go
+++ b/app/export.go
@@ -249,8 +249,15 @@ func (a *App) ExportAllPosts(writer io.Writer) *model.AppError {
return err
}
+ reactions, err := a.BuildPostReactions(post.Id)
+ if err != nil {
+ return err
+ }
+
postLine.Post.Replies = replies
+ postLine.Post.Reactions = reactions
+
if err := a.ExportWriteLine(writer, postLine); err != nil {
return err
}
@@ -272,8 +279,35 @@ func (a *App) buildPostReplies(postId string) (*[]ReplyImportData, *model.AppErr
replyPosts := result.Data.([]*model.ReplyForExport)
for _, reply := range replyPosts {
- replies = append(replies, *ImportReplyFromPost(reply))
+ replyImportObject := ImportReplyFromPost(reply)
+ if reply.HasReactions == true {
+ reactionsOfReply, err := a.BuildPostReactions(reply.Id)
+ if err != nil {
+ return nil, err
+ }
+ replyImportObject.Reactions = reactionsOfReply
+ }
+ replies = append(replies, *replyImportObject)
}
return &replies, nil
}
+
+func (a *App) BuildPostReactions(postId string) (*[]ReactionImportData, *model.AppError) {
+ var reactionsOfPost []ReactionImportData
+
+ result := <-a.Srv.Store.Reaction().GetForPost(postId, true)
+
+ if result.Err != nil {
+ return nil, result.Err
+ }
+
+ reactions := result.Data.([]*model.Reaction)
+
+ for _, reaction := range reactions {
+ reactionsOfPost = append(reactionsOfPost, *ImportReactionFromPost(reaction))
+ }
+
+ return &reactionsOfPost, nil
+
+}