-
Notifications
You must be signed in to change notification settings - Fork 405
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?
Changes from all commits
f963b82
e664088
58c6a79
fcb54a3
5f50fd5
76b86cf
8f78840
501257e
6d8c5c0
6148cb7
c187583
e119448
99eb9eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add an [Admin API](https://element-hq.github.io/synapse/latest/usage/administration/admin_api/index.html) to allow an admin | ||
to fetch the space/room hierarchy for a given space. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -821,7 +821,9 @@ def get_repo_and_check_clean_checkout( | |
f"{path} is not a git repository (expecting a {name} repository)." | ||
) | ||
while repo.is_dirty(): | ||
if not click.confirm(f"Uncommitted changes exist in {path}. Commit or stash them. Ready to continue?"): | ||
if not click.confirm( | ||
f"Uncommitted changes exist in {path}. Commit or stash them. Ready to continue?" | ||
): | ||
raise click.ClickException("Aborted.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was necessary to prevent the lint from failing, and stopping the rest of the tests from being run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now fixed on |
||
|
||
return repo | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,43 @@ | |
logger = logging.getLogger(__name__) | ||
|
||
|
||
class AdminRoomHierarchy(RestServlet): | ||
""" | ||
Given a room, returns room details on that room and any space children of the provided room. | ||
Does not reach out over federation to fetch details information about any remote rooms which | ||
the server is not currently participating in, returning only the room id of those rooms | ||
""" | ||
|
||
PATTERNS = admin_patterns("/rooms/(?P<room_id>[^/]*)/hierarchy$") | ||
|
||
def __init__(self, hs: "HomeServer"): | ||
self._auth = hs.get_auth() | ||
self._room_summary_handler = hs.get_room_summary_handler() | ||
self._store = hs.get_datastores().main | ||
self._storage_controllers = hs.get_storage_controllers() | ||
|
||
async def on_GET( | ||
self, request: SynapseRequest, room_id: str | ||
) -> Tuple[int, JsonDict]: | ||
requester = await self._auth.get_user_by_req(request) | ||
await assert_user_is_admin(self._auth, requester) | ||
|
||
max_depth = parse_integer(request, "max_depth") | ||
limit = parse_integer(request, "limit") | ||
|
||
room_entry_summary = await self._room_summary_handler.get_room_hierarchy( | ||
requester, | ||
room_id, | ||
omit_remote_room_hierarchy=True, # We omit details about remote rooms because we only care about managing rooms local to the homeserver. This also immensely helps with the response time of the endpoint since we don't need to reach out over federation. There is a trade-off as this will leave holes where information about public/peekable remote rooms the server is not participating in will be omitted. | ||
H-Shay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
admin_skip_room_visibility_check=True, | ||
max_depth=max_depth, | ||
limit=limit, | ||
from_token=parse_string(request, "from"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
) | ||
|
||
return HTTPStatus.OK, room_entry_summary | ||
|
||
|
||
class RoomRestV2Servlet(RestServlet): | ||
"""Delete a room from server asynchronously with a background task. | ||
|
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 description should be updated with the nuance that we return all known rooms but we won't go and fetch the hierarchy from federation which may leave holes. These rooms only have room_ids, etc