From ac0a928702853a17b36c793f44c778b6d883ebda Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Thu, 8 Nov 2018 14:55:45 +0000 Subject: [PATCH] Set prev_batch to 1 (first possible value in the sequence) if it's about to hit 0 --- .../matrix-org/dendrite/syncapi/storage/syncserver.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/syncapi/storage/syncserver.go b/src/github.com/matrix-org/dendrite/syncapi/storage/syncserver.go index e38aaaa3b..ec973e2c1 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/storage/syncserver.go +++ b/src/github.com/matrix-org/dendrite/syncapi/storage/syncserver.go @@ -313,7 +313,7 @@ func (d *SyncServerDatabase) CompleteSync( if prevBatch := recentStreamEvents[0].streamPosition - 1; prevBatch > 0 { jr.Timeline.PrevBatch = types.StreamPosition(prevBatch).String() } else { - jr.Timeline.PrevBatch = recentStreamEvents[0].streamPosition.String() + jr.Timeline.PrevBatch = types.StreamPosition(1).String() } jr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync) jr.Timeline.Limited = true @@ -447,7 +447,7 @@ func (d *SyncServerDatabase) addRoomDeltaToResponse( if prevBatch := recentStreamEvents[0].streamPosition - 1; prevBatch > 0 { jr.Timeline.PrevBatch = types.StreamPosition(prevBatch).String() } else { - jr.Timeline.PrevBatch = recentStreamEvents[0].streamPosition.String() + jr.Timeline.PrevBatch = types.StreamPosition(1).String() } jr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync) jr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true @@ -462,7 +462,7 @@ func (d *SyncServerDatabase) addRoomDeltaToResponse( if prevBatch := recentStreamEvents[0].streamPosition - 1; prevBatch > 0 { lr.Timeline.PrevBatch = types.StreamPosition(prevBatch).String() } else { - lr.Timeline.PrevBatch = recentStreamEvents[0].streamPosition.String() + lr.Timeline.PrevBatch = types.StreamPosition(1).String() } lr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync) lr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true