Fix hierarchy returning 403 when room is accessible through federation

This commit is contained in:
Krishan 2024-05-15 02:57:24 +10:00
parent 38f03a09ff
commit 3ef23d6f07

View file

@ -183,8 +183,27 @@ class RoomSummaryHandler:
) -> JsonDict:
"""See docstring for SpaceSummaryHandler.get_room_hierarchy."""
# First of all, check that the room is accessible.
if not await self._is_local_room_accessible(requested_room_id, requester):
# First of all, check that the room is accessible locally.
# OR accessible through federation.
local_room = await self._store.is_host_joined(room_id, self._server_name)
if local_room and not await self._is_local_room_accessible(requested_room_id, requester):
raise UnstableSpecAuthError(
403,
"User %s not in room %s, and room previews are disabled"
% (requester, requested_room_id),
errcode=Codes.NOT_JOINED,
)
if not local_room:
(
room_entry,
children_room_entries,
inaccessible_children,
) = await self._summarize_remote_room_hierarchy(
_RoomQueueEntry(requested_room_id, ()),
False,
)
if not room_entry or not await self._is_remote_room_accessible(requester, requested_room_id, room_entry.room):
raise UnstableSpecAuthError(
403,
"User %s not in room %s, and room previews are disabled"