aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--syncapi/routing/context.go6
-rw-r--r--syncapi/syncapi_test.go2
2 files changed, 7 insertions, 1 deletions
diff --git a/syncapi/routing/context.go b/syncapi/routing/context.go
index b0c91c40..b136c69a 100644
--- a/syncapi/routing/context.go
+++ b/syncapi/routing/context.go
@@ -110,6 +110,7 @@ func Context(
}
stateFilter := synctypes.StateFilter{
+ Limit: filter.Limit,
NotSenders: filter.NotSenders,
NotTypes: filter.NotTypes,
Senders: filter.Senders,
@@ -157,6 +158,11 @@ func Context(
}
}
+ // Limit is split up for before/after events
+ if filter.Limit > 1 {
+ filter.Limit = filter.Limit / 2
+ }
+
eventsBefore, err := snapshot.SelectContextBeforeEvent(ctx, id, roomID, filter)
if err != nil && err != sql.ErrNoRows {
logrus.WithError(err).Error("unable to fetch before events")
diff --git a/syncapi/syncapi_test.go b/syncapi/syncapi_test.go
index 0a2c38ab..0392f209 100644
--- a/syncapi/syncapi_test.go
+++ b/syncapi/syncapi_test.go
@@ -1136,7 +1136,7 @@ func testContext(t *testing.T, dbType test.DBType) {
},
{
name: "events are not limited",
- wantBeforeLength: 7,
+ wantBeforeLength: 5,
},
{
name: "all events are limited",