diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2022-03-08 08:09:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 08:09:11 -0500 |
commit | ca9234a9eba4fba02d8d50e5d5eff079bfaf0ebd (patch) | |
tree | 7c72f823a7cb73fa06166cff9888ff590e354994 /synapse | |
parent | Fix incorrect type hints for txredis. (#12042) (diff) | |
download | synapse-ca9234a9eba4fba02d8d50e5d5eff079bfaf0ebd.tar.xz |
Do not return allowed_room_ids from /hierarchy response. (#12175)
This field is only to be used in the Server-Server API, and not the Client-Server API, but was being leaked when a federation response was used in the /hierarchy API.
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/handlers/room_summary.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/synapse/handlers/room_summary.py b/synapse/handlers/room_summary.py index 3979cbba71..486145f48a 100644 --- a/synapse/handlers/room_summary.py +++ b/synapse/handlers/room_summary.py @@ -295,7 +295,7 @@ class RoomSummaryHandler: # inaccessible to the requesting user. if room_entry: # Add the room (including the stripped m.space.child events). - rooms_result.append(room_entry.as_json()) + rooms_result.append(room_entry.as_json(for_client=True)) # If this room is not at the max-depth, check if there are any # children to process. @@ -843,14 +843,25 @@ class _RoomEntry: # This may not include all children. children_state_events: Sequence[JsonDict] = () - def as_json(self) -> JsonDict: + 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 result |