mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-04-19 02:03:39 +00:00
Fix end position in case of backward ordering
This commit is contained in:
parent
955dd2c96d
commit
b028a31f7f
1 changed files with 12 additions and 1 deletions
|
@ -220,7 +220,18 @@ func (r *messagesReq) retrieveEvents() (
|
||||||
types.PaginationTokenTypeTopology, streamEvents[len(streamEvents)-1].StreamPosition,
|
types.PaginationTokenTypeTopology, streamEvents[len(streamEvents)-1].StreamPosition,
|
||||||
)
|
)
|
||||||
|
|
||||||
if end.Position == types.StreamPosition(0) {
|
if r.backwardOrdering {
|
||||||
|
// 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.Position--
|
||||||
|
}
|
||||||
|
|
||||||
|
// The lowest token value is 1, therefore we need to manually set it to that
|
||||||
|
// value if we're below it.
|
||||||
|
if end.Position < types.StreamPosition(1) {
|
||||||
end.Position = types.StreamPosition(1)
|
end.Position = types.StreamPosition(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue