Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Additional comments for space summary handler #9974

Merged
merged 3 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/9974.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update comments in the space summary handler.
51 changes: 46 additions & 5 deletions synapse/handlers/space_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
logger = logging.getLogger(__name__)

# number of rooms to return. We'll stop once we hit this limit.
# TODO: allow clients to reduce this with a request param.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MSC has no mention of this, so I don't think mentioning it here makes sense.

MAX_ROOMS = 50

# max number of events to return per room.
Expand Down Expand Up @@ -231,11 +230,15 @@ async def _summarize_local_room(
Generate a room entry and a list of event entries for a given room.

Args:
requester: The requesting user, or None if this is over federation.
requester:
The user requesting the summary, if it is a local request. None
if this is a federation request.
room_id: The room ID to summarize.
suggested_only: True if only suggested children should be returned.
Otherwise, all children are returned.
max_children: The maximum number of children to return for this node.
max_children:
The maximum number of children rooms to include. This is capped
to a server-set limit.

Returns:
A tuple of:
Expand Down Expand Up @@ -278,6 +281,26 @@ async def _summarize_remote_room(
max_children: Optional[int],
exclude_rooms: Iterable[str],
) -> Tuple[Sequence[JsonDict], Sequence[JsonDict]]:
"""
Request room entries and a list of event entries for a given room by querying a remote server.

Args:
room: The room to summarize.
suggested_only: True if only suggested children should be returned.
Otherwise, all children are returned.
max_children:
The maximum number of children rooms to include. This is capped
to a server-set limit.
exclude_rooms:
Rooms IDs which do not need to be summarized.

Returns:
A tuple of:
An iterable of rooms.

An iterable of the sorted children events. This may be limited
to a maximum size or may include all children.
"""
room_id = room.room_id
logger.info("Requesting summary for %s via %s", room_id, room.via)

Expand Down Expand Up @@ -310,8 +333,26 @@ async def _summarize_remote_room(
)

async def _is_room_accessible(self, room_id: str, requester: Optional[str]) -> bool:
# if we have an authenticated requesting user, first check if they are in the
# room
"""
Calculate whether the room should be shown in the spaces summary.

It should be included if:

* The requester is joined or invited to the room.
* The history visibility is set to world readable.

Args:
room_id: The room ID to summarize.
requester:
The user requesting the summary, if it is a local request. None
if this is a federation request.

Returns:
True if the room should be included in the spaces summary.
"""

# if we have an authenticated requesting user, first check if they are able to view
# stripped state in the room.
if requester:
try:
await self._auth.check_user_in_room(room_id, requester)
Expand Down