diff --git a/mm-go-irckit/service.go b/mm-go-irckit/service.go index 1b3bbcef..ca044ca2 100644 --- a/mm-go-irckit/service.go +++ b/mm-go-irckit/service.go @@ -342,12 +342,27 @@ func scrollback(u *User, toUser *User, args []string, service string) { postlist, _ := list.(*model.PostList) - for i := len(postlist.Order) - 1; i >= 0; i-- { - if limit != 0 && len(postlist.Order) > limit && i < len(postlist.Order)-limit { + // Workaround https://github.com/mattermost/mattermost-server/issues/23081 + plOrder := postlist.Order + if searchPostID != "" { + plOrder = append(plOrder, searchPostID) + } + skipRoot := false + + for i := len(plOrder) - 1; i >= 0; i-- { + if limit != 0 && len(plOrder) > limit && i < len(plOrder)-limit { continue } - p := postlist.Posts[postlist.Order[i]] + p := postlist.Posts[plOrder[i]] + + // Workaround https://github.com/mattermost/mattermost-server/issues/23081 + if searchPostID != "" && p.Id == searchPostID { + if skipRoot { + continue + } + skipRoot = true + } props := p.GetProps() botname, override := props["override_username"].(string)