Skip to content

Commit

Permalink
Workaround ordering returned by GetPostThread API call
Browse files Browse the repository at this point in the history
  • Loading branch information
hloeung committed Apr 22, 2023
1 parent a69a19f commit f52a956
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions mm-go-irckit/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f52a956

Please # to comment.