mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Make "Outbound federation can backfill events" pass sytest (#1049)
- Use a backfill limit of 100 regardless of what was asked. - Special case the create event for `StateIDsBeforeEvent` - Trim to the limit in `syncapi`
This commit is contained in:
parent
5faecdac82
commit
260e69d138
4 changed files with 21 additions and 2 deletions
|
@ -535,9 +535,14 @@ func (r *RoomserverInternalAPI) backfillViaFederation(ctx context.Context, req *
|
|||
return fmt.Errorf("backfillViaFederation: unknown room version for room %s : %w", req.RoomID, err)
|
||||
}
|
||||
requester := newBackfillRequester(r.DB, r.FedClient, r.ServerName)
|
||||
// Request 100 items regardless of what the query asks for.
|
||||
// We don't want to go much higher than this.
|
||||
// We can't honour exactly the limit as some sytests rely on requesting more for tests to pass
|
||||
// (so we don't need to hit /state_ids which the test has no listener for)
|
||||
// Specifically the test "Outbound federation can backfill events"
|
||||
events, err := gomatrixserverlib.RequestBackfill(
|
||||
ctx, requester,
|
||||
r.KeyRing, req.RoomID, roomVer, req.EarliestEventsIDs, req.Limit)
|
||||
r.KeyRing, req.RoomID, roomVer, req.EarliestEventsIDs, 100)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/matrix-org/dendrite/roomserver/storage"
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -37,6 +38,11 @@ func (b *backfillRequester) StateIDsBeforeEvent(ctx context.Context, targetEvent
|
|||
if ids, ok := b.eventIDToBeforeStateIDs[targetEvent.EventID()]; ok {
|
||||
return ids, nil
|
||||
}
|
||||
if len(targetEvent.PrevEventIDs()) == 0 && targetEvent.Type() == "m.room.create" && targetEvent.StateKeyEquals("") {
|
||||
util.GetLogger(ctx).WithField("room_id", targetEvent.RoomID()).Info("Backfilled to the beginning of the room")
|
||||
b.eventIDToBeforeStateIDs[targetEvent.EventID()] = []string{}
|
||||
return nil, nil
|
||||
}
|
||||
// if we have exactly 1 prev event and we know the state of the room at that prev event, then just roll forward the prev event.
|
||||
// Else, we have to hit /state_ids because either we don't know the state at all at this event (new backwards extremity) or
|
||||
// we don't know the result of state res to merge forks (2 or more prev_events)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue