From fc0dbe0ace7414bfad5ac76bb2ed02cc99612194 Mon Sep 17 00:00:00 2001 From: Eli Yukelzon Date: Thu, 29 Apr 2021 14:58:19 +0300 Subject: [PATCH] MM-35206 CRT: is_following on posts not reflecting state properly (#17533) * forgot to copy isFollowing param * /thread API didn't return thread posts, just the root * cleanup * [ci] Co-authored-by: Mattermod --- model/post.go | 1 + store/sqlstore/post_store.go | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/model/post.go b/model/post.go index fe5df8347b..c305cd8207 100644 --- a/model/post.go +++ b/model/post.go @@ -207,6 +207,7 @@ func (o *Post) ShallowCopy(dst *Post) error { dst.Participants = o.Participants dst.LastReplyAt = o.LastReplyAt dst.Metadata = o.Metadata + dst.IsFollowing = o.IsFollowing dst.RemoteId = o.RemoteId return nil } diff --git a/store/sqlstore/post_store.go b/store/sqlstore/post_store.go index 73a2928864..9fe2b07729 100644 --- a/store/sqlstore/post_store.go +++ b/store/sqlstore/post_store.go @@ -474,7 +474,22 @@ func (s *SqlPostStore) getPostWithCollapsedThreads(id, userID string, extended b return nil, errors.Wrapf(err, "failed to get Post with id=%s", id) } - return s.prepareThreadedResponse([]*postWithExtra{&post}, extended, false) + + var posts []*model.Post + _, err = s.GetReplica().Select(&posts, "SELECT * FROM Posts WHERE Posts.RootId = :RootId AND DeleteAt = 0", map[string]interface{}{"RootId": id}) + if err != nil { + return nil, errors.Wrapf(err, "failed to find Posts for thread %s", id) + } + + list, err := s.prepareThreadedResponse([]*postWithExtra{&post}, extended, false) + if err != nil { + return nil, err + } + for _, p := range posts { + list.AddPost(p) + list.AddOrder(p.Id) + } + return list, nil } func (s *SqlPostStore) Get(ctx context.Context, id string, skipFetchThreads, collapsedThreads, collapsedThreadsExtended bool, userID string) (*model.PostList, error) {