aboutsummaryrefslogtreecommitdiff
path: root/syncapi/routing
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-07-01 11:49:26 +0200
committerGitHub <noreply@github.com>2022-07-01 11:49:26 +0200
commit89cd0e8fc13b040470aebe2eb4d36a9235b1473d (patch)
tree3682144f9697e7b139b3dab1f2a1c1c7bd5114b6 /syncapi/routing
parent086f182e24e0651d1320199e90215f280350ef44 (diff)
Try to fix backfilling (#2548)
* Try to fix backfilling * Return start/end to not confuse clients * Update GMSL * Update GMSL
Diffstat (limited to 'syncapi/routing')
-rw-r--r--syncapi/routing/context.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/syncapi/routing/context.go b/syncapi/routing/context.go
index d021d365..f6b4d15e 100644
--- a/syncapi/routing/context.go
+++ b/syncapi/routing/context.go
@@ -15,6 +15,7 @@
package routing
import (
+ "context"
"database/sql"
"encoding/json"
"fmt"
@@ -25,6 +26,7 @@ import (
"github.com/matrix-org/dendrite/internal/caching"
roomserver "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/syncapi/storage"
+ "github.com/matrix-org/dendrite/syncapi/types"
userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
@@ -149,13 +151,30 @@ func Context(
if len(response.State) > filter.Limit {
response.State = response.State[len(response.State)-filter.Limit:]
}
-
+ start, end, err := getStartEnd(ctx, syncDB, eventsBefore, eventsAfter)
+ if err == nil {
+ response.End = end.String()
+ response.Start = start.String()
+ }
return util.JSONResponse{
Code: http.StatusOK,
JSON: response,
}
}
+func getStartEnd(ctx context.Context, syncDB storage.Database, startEvents, endEvents []*gomatrixserverlib.HeaderedEvent) (start, end types.TopologyToken, err error) {
+ if len(startEvents) > 0 {
+ start, err = syncDB.EventPositionInTopology(ctx, startEvents[0].EventID())
+ if err != nil {
+ return
+ }
+ }
+ if len(endEvents) > 0 {
+ end, err = syncDB.EventPositionInTopology(ctx, endEvents[0].EventID())
+ }
+ return
+}
+
func applyLazyLoadMembers(
device *userapi.Device,
filter *gomatrixserverlib.RoomEventFilter,