mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-06 22:43:10 -06:00
Don't walk inaccessible rooms
This commit is contained in:
parent
2e88c7247c
commit
3d18878001
|
|
@ -142,6 +142,7 @@ func (querier *Queryer) QueryNextRoomHierarchyPage(ctx context.Context, walker r
|
||||||
}
|
}
|
||||||
} else if !authorised {
|
} else if !authorised {
|
||||||
inaccessible = append(inaccessible, queuedRoom.RoomID.String())
|
inaccessible = append(inaccessible, queuedRoom.RoomID.String())
|
||||||
|
continue
|
||||||
} else {
|
} else {
|
||||||
// room exists but user is not authorised
|
// room exists but user is not authorised
|
||||||
continue
|
continue
|
||||||
|
|
@ -158,6 +159,7 @@ func (querier *Queryer) QueryNextRoomHierarchyPage(ctx context.Context, walker r
|
||||||
// We need to invert the order here because the child events are lo->hi on the timestamp,
|
// We need to invert the order here because the child events are lo->hi on the timestamp,
|
||||||
// so we need to ensure we pop in the same lo->hi order, which won't be the case if we
|
// so we need to ensure we pop in the same lo->hi order, which won't be the case if we
|
||||||
// insert the highest timestamp last in a stack.
|
// insert the highest timestamp last in a stack.
|
||||||
|
extendQueueLoop:
|
||||||
for i := len(discoveredChildEvents) - 1; i >= 0; i-- {
|
for i := len(discoveredChildEvents) - 1; i >= 0; i-- {
|
||||||
spaceContent := struct {
|
spaceContent := struct {
|
||||||
Via []string `json:"via"`
|
Via []string `json:"via"`
|
||||||
|
|
@ -170,6 +172,12 @@ func (querier *Queryer) QueryNextRoomHierarchyPage(ctx context.Context, walker r
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.GetLogger(ctx).WithError(err).WithField("invalid_room_id", ev.StateKey).WithField("parent_room_id", queuedRoom.RoomID).Warn("Invalid room ID in m.space.child state event")
|
util.GetLogger(ctx).WithError(err).WithField("invalid_room_id", ev.StateKey).WithField("parent_room_id", queuedRoom.RoomID).Warn("Invalid room ID in m.space.child state event")
|
||||||
} else {
|
} else {
|
||||||
|
// Make sure not to queue inaccessible rooms
|
||||||
|
for _, inaccessibleRoomID := range inaccessible {
|
||||||
|
if inaccessibleRoomID == childRoomID.String() {
|
||||||
|
continue extendQueueLoop
|
||||||
|
}
|
||||||
|
}
|
||||||
unvisited = append(unvisited, roomserver.RoomHierarchyWalkerQueuedRoom{
|
unvisited = append(unvisited, roomserver.RoomHierarchyWalkerQueuedRoom{
|
||||||
RoomID: *childRoomID,
|
RoomID: *childRoomID,
|
||||||
ParentRoomID: &queuedRoom.RoomID,
|
ParentRoomID: &queuedRoom.RoomID,
|
||||||
|
|
@ -257,7 +265,7 @@ func authorisedServer(ctx context.Context, querier *Queryer, roomID spec.RoomID,
|
||||||
return true, []string{}
|
return true, []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rule == spec.Restricted {
|
if rule == spec.Restricted || rule == spec.KnockRestricted {
|
||||||
allowJoinedToRoomIDs = append(allowJoinedToRoomIDs, restrictedJoinRuleAllowedRooms(ctx, joinRuleEv)...)
|
allowJoinedToRoomIDs = append(allowJoinedToRoomIDs, restrictedJoinRuleAllowedRooms(ctx, joinRuleEv)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue