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,10 @@ class RoomSummaryHandler:
) -> JsonDict: ) -> JsonDict:
"""See docstring for SpaceSummaryHandler.get_room_hierarchy.""" """See docstring for SpaceSummaryHandler.get_room_hierarchy."""
# First of all, check that the room is accessible. # First of all, check that the room is accessible locally.
if not await self._is_local_room_accessible(requested_room_id, requester): # 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( raise UnstableSpecAuthError(
403, 403,
"User %s not in room %s, and room previews are disabled" "User %s not in room %s, and room previews are disabled"
@ -192,6 +194,23 @@ class RoomSummaryHandler:
errcode=Codes.NOT_JOINED, 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"
% (requester, requested_room_id),
errcode=Codes.NOT_JOINED,
)
# If this is continuing a previous session, pull the persisted data. # If this is continuing a previous session, pull the persisted data.
if from_token: if from_token:
try: try: