Tweaks around /messages (#3149)

Try to mitigate some issues with `/messages`
This commit is contained in:
Till 2023-07-13 14:18:37 +02:00 committed by GitHub
parent 0df982a2e5
commit f12982472c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 182 additions and 88 deletions

View file

@ -237,7 +237,7 @@ func (d *DatabaseTransaction) GetEventsInTopologicalRange(
roomID string,
filter *synctypes.RoomEventFilter,
backwardOrdering bool,
) (events []types.StreamEvent, err error) {
) (events []types.StreamEvent, start, end types.TopologyToken, err error) {
var minDepth, maxDepth, maxStreamPosForMaxDepth types.StreamPosition
if backwardOrdering {
// Backward ordering means the 'from' token has a higher depth than the 'to' token
@ -255,7 +255,7 @@ func (d *DatabaseTransaction) GetEventsInTopologicalRange(
// Select the event IDs from the defined range.
var eIDs []string
eIDs, err = d.Topology.SelectEventIDsInRange(
eIDs, start, end, err = d.Topology.SelectEventIDsInRange(
ctx, d.txn, roomID, minDepth, maxDepth, maxStreamPosForMaxDepth, filter.Limit, !backwardOrdering,
)
if err != nil {
@ -264,6 +264,10 @@ func (d *DatabaseTransaction) GetEventsInTopologicalRange(
// Retrieve the events' contents using their IDs.
events, err = d.OutputEvents.SelectEvents(ctx, d.txn, eIDs, filter, true)
if err != nil {
return
}
return
}