mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-09 01:15:04 -04:00
Support the stable /hierarchy endpoint from MSC2946 (#11329)
This also makes additional updates where the implementation had drifted from the approved MSC. Unstable endpoints will be removed at a later data.
This commit is contained in:
parent
d08ef6f155
commit
a4521ce0a8
11 changed files with 134 additions and 51 deletions
|
@ -1395,11 +1395,28 @@ class FederationClient(FederationBase):
|
|||
async def send_request(
|
||||
destination: str,
|
||||
) -> Tuple[JsonDict, Sequence[JsonDict], Sequence[str]]:
|
||||
res = await self.transport_layer.get_room_hierarchy(
|
||||
destination=destination,
|
||||
room_id=room_id,
|
||||
suggested_only=suggested_only,
|
||||
)
|
||||
try:
|
||||
res = await self.transport_layer.get_room_hierarchy(
|
||||
destination=destination,
|
||||
room_id=room_id,
|
||||
suggested_only=suggested_only,
|
||||
)
|
||||
except HttpResponseException as e:
|
||||
# If an error is received that is due to an unrecognised endpoint,
|
||||
# fallback to the unstable endpoint. Otherwise consider it a
|
||||
# legitmate error and raise.
|
||||
if not self._is_unknown_endpoint(e):
|
||||
raise
|
||||
|
||||
logger.debug(
|
||||
"Couldn't fetch room hierarchy with the v1 API, falling back to the unstable API"
|
||||
)
|
||||
|
||||
res = await self.transport_layer.get_room_hierarchy_unstable(
|
||||
destination=destination,
|
||||
room_id=room_id,
|
||||
suggested_only=suggested_only,
|
||||
)
|
||||
|
||||
room = res.get("room")
|
||||
if not isinstance(room, dict):
|
||||
|
@ -1449,6 +1466,10 @@ class FederationClient(FederationBase):
|
|||
if e.code != 502:
|
||||
raise
|
||||
|
||||
logger.debug(
|
||||
"Couldn't fetch room hierarchy, falling back to the spaces API"
|
||||
)
|
||||
|
||||
# Fallback to the old federation API and translate the results if
|
||||
# no servers implement the new API.
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue