-
Notifications
You must be signed in to change notification settings - Fork 404
Add an admin API to search for children of a room #19021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
test failures appear to be flakes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't reviewed the code much as there may be a potential pivot (see review comments)
|
failures look like flakes |
tests/rest/admin/test_room.py
Outdated
| # only room_id and children_state fields are returned for remote rooms | ||
| self.assertEqual(len(room_result["children_state"]), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a little misleading as it's unknown, not zero. Feels like this should be left unset in the remote room cases that we don't fetch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default entry for _RoomEntry is ()
@attr.s(frozen=True, slots=True, auto_attribs=True)
class _RoomEntry:
room_id: str
# The room summary for this room.
room: JsonDict
# An iterable of the sorted, stripped children events for children of this room.
#
# This may not include all children.
children_state_events: Sequence[JsonDict] = ()which gets converted to json for the response by this:
def as_json(self, for_client: bool = False) -> JsonDict:
"""
Returns a JSON dictionary suitable for the room hierarchy endpoint.
It returns the room summary including the stripped m.space.child events
as a sub-key.
Args:
for_client: If true, any server-server only fields are stripped from
the result.
"""
result = dict(self.room)
# Before returning to the client, remove the allowed_room_ids key, if it
# exists.
if for_client:
result.pop("allowed_room_ids", False)
result["children_state"] = self.children_state_events
return resultSo I think to leave children_state unset I think we'd have to change the structure of _Room_Entry to an optional and have as_json omit children_state in the case where self.children_state is None, but that seems clunkier than having the children_state be an empty list in the case of remote rooms we don't fetch - thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if this could be addressed by adding a comment about the face that children_state is unknown in the case of remote rooms in the endpoint documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about this more, I think we can just omit remote rooms altogether (no need for bare room_id entries). The client can still find the unknown remote rooms via the m.space.child in the children_state of the space. Further thoughts tracked in matrix-org/matrix-spec#2237
It still makes sense to call the option omit_remote_room_hierarchy and we just need to remove this part: #19021 (comment)
| {"room2", "room3", "remote_room"}, | ||
| ) | ||
|
|
||
| for room_result in rooms: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only testing the rooms from the first request 😬
rooms = rooms + new_rooms was removed in b187d6f
Perhaps we should just put this in a helper self._assert_expected_rooms_have_correct_fields(rooms) and call this after each request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it in the last round so that each request was being asserted on separately for only the rooms that should have been returned from each request - I think this should be fine and not necessitate a helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do this for both tests so could simplify down to a helper.
Otherwise, we probably want to have an else clause for unknown rooms even though we're asserting specific rooms above in the assertCountEqual.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a an else clause to fail the return of an unknown room (line 356 and 271 - sorry can't figure out how to link a line in a PR diff in the UI), would that suffice?
synapse/handlers/room_summary.py
Outdated
| # if we are not fetching remote room details over federation, return what is | ||
| # known about the room | ||
| elif omit_remote_room_hierarchy: | ||
| room_entry = _RoomEntry(room_id, {"room_id": room_id}, ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(marking part to remove)
See other discussion, #19021 (comment)
tests/rest/admin/test_room.py
Outdated
| # only room_id and children_state fields are returned for remote rooms | ||
| self.assertEqual(len(room_result["children_state"]), 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about this more, I think we can just omit remote rooms altogether (no need for bare room_id entries). The client can still find the unknown remote rooms via the m.space.child in the children_state of the space. Further thoughts tracked in matrix-org/matrix-spec#2237
It still makes sense to call the option omit_remote_room_hierarchy and we just need to remove this part: #19021 (comment)
It is often useful when investigating a space to get information about that space and it's children. This PR adds an Admin API to return information about a space and it's children, regardless of room membership. Will not return information about remote rooms that the server is not participating in.