MM-17339: fix missing post thread (#11729)
* leverage testify for TestGetPostsForChannelAroundLastUnread * introduce assertPostList helper * unit test MM-17339 * fix MM-17339
Этот коммит содержится в:
коммит произвёл
Saturnino Abril
родитель
e2ef5d7149
Коммит
f44473e062
22
app/post.go
22
app/post.go
@@ -771,27 +771,33 @@ func (a *App) GetPostsForChannelAroundLastUnread(channelId, userId string, limit
|
||||
return model.NewPostList(), nil
|
||||
}
|
||||
|
||||
lastUnreadPost, err := a.GetPostAfterTime(channelId, member.LastViewedAt)
|
||||
lastUnreadPostId, err := a.GetPostIdAfterTime(channelId, member.LastViewedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if lastUnreadPost == nil {
|
||||
} else if lastUnreadPostId == "" {
|
||||
return model.NewPostList(), nil
|
||||
}
|
||||
|
||||
var postList *model.PostList
|
||||
if postList, err = a.GetPostsBeforePost(channelId, lastUnreadPost.Id, PAGE_DEFAULT, limitBefore); err != nil {
|
||||
postList, err := a.GetPostThread(lastUnreadPostId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Reset order to only include the last unread post: if the thread appears in the centre
|
||||
// channel organically, those replies will be added below.
|
||||
postList.Order = []string{lastUnreadPostId}
|
||||
|
||||
if postListAfter, err := a.GetPostsAfterPost(channelId, lastUnreadPost.Id, PAGE_DEFAULT, limitAfter-1); err != nil {
|
||||
if postListBefore, err := a.GetPostsBeforePost(channelId, lastUnreadPostId, PAGE_DEFAULT, limitBefore); err != nil {
|
||||
return nil, err
|
||||
} else if postListBefore != nil {
|
||||
postList.Extend(postListBefore)
|
||||
}
|
||||
|
||||
if postListAfter, err := a.GetPostsAfterPost(channelId, lastUnreadPostId, PAGE_DEFAULT, limitAfter-1); err != nil {
|
||||
return nil, err
|
||||
} else if postListAfter != nil {
|
||||
postList.Extend(postListAfter)
|
||||
}
|
||||
|
||||
postList.AddPost(lastUnreadPost)
|
||||
postList.AddOrder(lastUnreadPost.Id)
|
||||
|
||||
postList.SortByCreateAt()
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user