NOTSPEC: Re-add iOS end of topology

This commit is contained in:
Neil Alexander 2021-01-13 12:46:28 +00:00
parent 1fe673e11d
commit 75291c6f4e
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -390,16 +390,21 @@ func (r *messagesReq) filterHistoryVisible(events []*gomatrixserverlib.HeaderedE
func (r *messagesReq) getStartEnd(events []*gomatrixserverlib.HeaderedEvent) (start, end types.TopologyToken, err error) {
if r.backwardOrdering {
start = *r.from
end, err = r.db.EventPositionInTopology(
r.ctx, events[0].EventID(),
)
// A stream/topological position is a cursor located between two events.
// While they are identified in the code by the event on their right (if
// we consider a left to right chronological order), tokens need to refer
// to them by the event on their left, therefore we need to decrement the
// end position we send in the response if we're going backward.
end.Decrement()
if events[len(events)-1].Type() == gomatrixserverlib.MRoomCreate {
// NOTSPEC: We've hit the beginning of the room so there's really nowhere
// else to go. This seems to fix Riot iOS from looping on /messages endlessly.
end = types.TopologyToken{}
} else {
end, err = r.db.EventPositionInTopology(
r.ctx, events[0].EventID(),
)
// A stream/topological position is a cursor located between two events.
// While they are identified in the code by the event on their right (if
// we consider a left to right chronological order), tokens need to refer
// to them by the event on their left, therefore we need to decrement the
// end position we send in the response if we're going backward.
end.Decrement()
}
} else {
start = *r.from
end, err = r.db.EventPositionInTopology(