mirror of
https://github.com/matrix-org/dendrite
synced 2024-10-31 21:19:04 +01:00
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>
This commit is contained in:
parent
41c0b5acfb
commit
af41fcadc4
1 changed files with 9 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue