mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-22 06:11:55 -06:00
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:
parent
ecb7b383e9
commit
8f944f6434
|
@ -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")
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue