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 <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Eli Yukelzon
2021-04-29 14:58:19 +03:00
коммит произвёл GitHub
родитель 611e03de94
Коммит fc0dbe0ace
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@@ -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
}

Просмотреть файл

@@ -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) {