From 1cdea0fd02bb2f7e64495d39e8e3d64451cf58ab Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Wed, 16 Aug 2017 17:29:18 +0100 Subject: [PATCH] Fix computation of next public rooms batch --- .../dendrite/publicroomsapi/directory/public_rooms.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/publicroomsapi/directory/public_rooms.go b/src/github.com/matrix-org/dendrite/publicroomsapi/directory/public_rooms.go index ea99636e2..4566715c2 100644 --- a/src/github.com/matrix-org/dendrite/publicroomsapi/directory/public_rooms.go +++ b/src/github.com/matrix-org/dendrite/publicroomsapi/directory/public_rooms.go @@ -70,8 +70,9 @@ func GetPublicRooms( if offset > 0 { response.PrevBatch = strconv.Itoa(int(offset) - 1) } - if response.Estimate > int64(limit) { - response.NextBatch = strconv.Itoa(int(offset) + int(limit)) + nextIndex := int(offset) + int(limit) + if response.Estimate > int64(nextIndex) { + response.NextBatch = strconv.Itoa(nextIndex) } if response.Chunk, err = publicRoomDatabase.GetPublicRooms(offset, limit, request.Filter.SearchTerms); err != nil {