Limit filter to limit/2 for before/after events on /context (#3332)

Part of https://github.com/matrix-org/dendrite/issues/3224
This commit is contained in:
Till 2024-02-20 08:38:51 +01:00 committed by GitHub
parent ecb7b383e9
commit 8f944f6434
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -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")

View file

@ -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",