diff options
author | Mayeul Cantan <mayeul.cantan@gmail.com> | 2020-11-16 11:47:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 10:47:16 +0000 |
commit | af41fcadc49fb99e142d134a2d451bb0b0672699 (patch) | |
tree | 475b824ec1567e1dc266d8f2f4d49da59f92fb1c | |
parent | 41c0b5acfb3bbb2a4b1985862421f6fb1b11772d (diff) |
Fix Dendrite not backfilling on world_readable rooms (#1575)
The previous implementation was only checking if room history was
"shared", which it wasn't for rooms where a user was invited, or world
readable rooms.
This implementation leverages the IsServerAllowed method, which already
implements the complete verification algorithm.
Signed-off-by: `Mayeul Cantan <oss+matrix@mayeul.net>`
Co-authored-by: Kegsay <kegan@matrix.org>
-rw-r--r-- | roomserver/internal/perform/perform_backfill.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/roomserver/internal/perform/perform_backfill.go b/roomserver/internal/perform/perform_backfill.go index d90ac8fc..6c05b3b8 100644 --- a/roomserver/internal/perform/perform_backfill.go +++ b/roomserver/internal/perform/perform_backfill.go @@ -426,7 +426,7 @@ FindSuccessor: } // possibly return all joined servers depending on history visiblity - memberEventsFromVis, err := joinEventsFromHistoryVisibility(ctx, b.db, roomID, stateEntries) + memberEventsFromVis, err := joinEventsFromHistoryVisibility(ctx, b.db, roomID, stateEntries, b.thisServer) if err != nil { logrus.WithError(err).Error("ServersAtEvent: failed calculate servers from history visibility rules") return nil @@ -501,11 +501,12 @@ func (b *backfillRequester) ProvideEvents(roomVer gomatrixserverlib.RoomVersion, return events, nil } -// joinEventsFromHistoryVisibility returns all CURRENTLY joined members if the provided state indicated a 'shared' history visibility. +// joinEventsFromHistoryVisibility returns all CURRENTLY joined members if our server can read the room history // TODO: Long term we probably want a history_visibility table which stores eventNID | visibility_enum so we can just // pull all events and then filter by that table. func joinEventsFromHistoryVisibility( - ctx context.Context, db storage.Database, roomID string, stateEntries []types.StateEntry) ([]types.Event, error) { + ctx context.Context, db storage.Database, roomID string, stateEntries []types.StateEntry, + thisServer gomatrixserverlib.ServerName) ([]types.Event, error) { var eventNIDs []types.EventNID for _, entry := range stateEntries { @@ -525,9 +526,11 @@ func joinEventsFromHistoryVisibility( for i := range stateEvents { events[i] = stateEvents[i].Event } - visibility := auth.HistoryVisibilityForRoom(events) - if visibility != "shared" { - logrus.Infof("ServersAtEvent history visibility not shared: %s", visibility) + + // Can we see events in the room? + canSeeEvents := auth.IsServerAllowed(thisServer, true, events) + if !canSeeEvents { + logrus.Infof("ServersAtEvent history not visible to us: %s", auth.HistoryVisibilityForRoom(events)) return nil, nil } // get joined members |