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) { func (r *messagesReq) getStartEnd(events []*gomatrixserverlib.HeaderedEvent) (start, end types.TopologyToken, err error) {
if r.backwardOrdering { if r.backwardOrdering {
start = *r.from start = *r.from
end, err = r.db.EventPositionInTopology( if events[len(events)-1].Type() == gomatrixserverlib.MRoomCreate {
r.ctx, events[0].EventID(), // 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{}
// A stream/topological position is a cursor located between two events. } else {
// While they are identified in the code by the event on their right (if end, err = r.db.EventPositionInTopology(
// we consider a left to right chronological order), tokens need to refer r.ctx, events[0].EventID(),
// 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. // A stream/topological position is a cursor located between two events.
end.Decrement() // 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 { } else {
start = *r.from start = *r.from
end, err = r.db.EventPositionInTopology( end, err = r.db.EventPositionInTopology(