diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2024-02-20 08:38:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-20 07:38:51 +0000 |
commit | 8f944f64349be6c434d5e47d9453c85db82d0144 (patch) | |
tree | 6e34afc764d261ab5a5405ec0e25c824f0d68a0e /syncapi | |
parent | ecb7b383e99489839b75c0f5ab2cf6e853780bb1 (diff) |
Limit filter to `limit/2` for before/after events on `/context` (#3332)
Part of https://github.com/matrix-org/dendrite/issues/3224
Diffstat (limited to 'syncapi')
-rw-r--r-- | syncapi/routing/context.go | 6 | ||||
-rw-r--r-- | syncapi/syncapi_test.go | 2 |
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", |