mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-08 18:16:59 +00:00
Fix backfilling (#3117)
This should fix two issues with backfilling: 1. right after creating and joining a room over federation, we are doing a `/backfill` request, which would return redacted events, because the `authEvents` are empty. Even though the spec states that, in the absence of a history visibility event, it should be handled as `shared`. 2. `gomatrixserverlib: unsupported room version ''` - because, well, we were never setting the `roomInfo` field..
This commit is contained in:
parent
d13466c1ee
commit
a734b112c6
@ -30,10 +30,6 @@ func IsServerAllowed(
|
||||
serverCurrentlyInRoom bool,
|
||||
authEvents []gomatrixserverlib.PDU,
|
||||
) bool {
|
||||
// In practice should not happen, but avoids unneeded CPU cycles
|
||||
if serverName == "" || len(authEvents) == 0 {
|
||||
return false
|
||||
}
|
||||
historyVisibility := HistoryVisibilityForRoom(authEvents)
|
||||
|
||||
// 1. If the history_visibility was set to world_readable, allow.
|
||||
|
@ -114,7 +114,7 @@ func (r *Backfiller) backfillViaFederation(ctx context.Context, req *api.Perform
|
||||
if info == nil || info.IsStub() {
|
||||
return fmt.Errorf("backfillViaFederation: missing room info for room %s", req.RoomID)
|
||||
}
|
||||
requester := newBackfillRequester(r.DB, r.FSAPI, r.Querier, req.VirtualHost, r.IsLocalServerName, req.BackwardsExtremities, r.PreferServers)
|
||||
requester := newBackfillRequester(r.DB, r.FSAPI, r.Querier, req.VirtualHost, r.IsLocalServerName, req.BackwardsExtremities, r.PreferServers, info.RoomVersion)
|
||||
// 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
|
||||
@ -265,7 +265,7 @@ type backfillRequester struct {
|
||||
eventIDToBeforeStateIDs map[string][]string
|
||||
eventIDMap map[string]gomatrixserverlib.PDU
|
||||
historyVisiblity gomatrixserverlib.HistoryVisibility
|
||||
roomInfo types.RoomInfo
|
||||
roomVersion gomatrixserverlib.RoomVersion
|
||||
}
|
||||
|
||||
func newBackfillRequester(
|
||||
@ -274,6 +274,7 @@ func newBackfillRequester(
|
||||
virtualHost spec.ServerName,
|
||||
isLocalServerName func(spec.ServerName) bool,
|
||||
bwExtrems map[string][]string, preferServers []spec.ServerName,
|
||||
roomVersion gomatrixserverlib.RoomVersion,
|
||||
) *backfillRequester {
|
||||
preferServer := make(map[spec.ServerName]bool)
|
||||
for _, p := range preferServers {
|
||||
@ -290,6 +291,7 @@ func newBackfillRequester(
|
||||
bwExtrems: bwExtrems,
|
||||
preferServer: preferServer,
|
||||
historyVisiblity: gomatrixserverlib.HistoryVisibilityShared,
|
||||
roomVersion: roomVersion,
|
||||
}
|
||||
}
|
||||
|
||||
@ -537,15 +539,11 @@ func (b *backfillRequester) ProvideEvents(roomVer gomatrixserverlib.RoomVersion,
|
||||
}
|
||||
eventNIDs := make([]types.EventNID, len(nidMap))
|
||||
i := 0
|
||||
roomNID := b.roomInfo.RoomNID
|
||||
for _, nid := range nidMap {
|
||||
eventNIDs[i] = nid.EventNID
|
||||
i++
|
||||
if roomNID == 0 {
|
||||
roomNID = nid.RoomNID
|
||||
}
|
||||
}
|
||||
eventsWithNids, err := b.db.Events(ctx, b.roomInfo.RoomVersion, eventNIDs)
|
||||
eventsWithNids, err := b.db.Events(ctx, b.roomVersion, eventNIDs)
|
||||
if err != nil {
|
||||
logrus.WithError(err).WithField("event_nids", eventNIDs).Error("Failed to load events")
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user