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

Commit f4833e0

Browse files
authored
Support fetching the spaces summary via GET over federation. (#9947)
Per changes in MSC2946, the C-S and S-S APIs for spaces summary should use GET requests. Until this is stable, the POST endpoints still exist. This does not switch federation requests to use the GET version yet since it is newly added and already deployed servers might not support it. When switching to the stable endpoint we should switch to GET requests.
1 parent 28c6841 commit f4833e0

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

changelog.d/9947.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update support for [MSC2946](https://github.com/matrix-org/matrix-doc/pull/2946): Spaces Summary.

synapse/federation/transport/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ async def get_space_summary(
995995
returned per space
996996
exclude_rooms: a list of any rooms we can skip
997997
"""
998+
# TODO When switching to the stable endpoint, use GET instead of POST.
998999
path = _create_path(
9991000
FEDERATION_UNSTABLE_PREFIX, "/org.matrix.msc2946/spaces/%s", room_id
10001001
)

synapse/federation/transport/server.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,32 @@ class FederationSpaceSummaryServlet(BaseFederationServlet):
13761376
PREFIX = FEDERATION_UNSTABLE_PREFIX + "/org.matrix.msc2946"
13771377
PATH = "/spaces/(?P<room_id>[^/]*)"
13781378

1379+
async def on_GET(
1380+
self,
1381+
origin: str,
1382+
content: JsonDict,
1383+
query: Mapping[bytes, Sequence[bytes]],
1384+
room_id: str,
1385+
) -> Tuple[int, JsonDict]:
1386+
suggested_only = parse_boolean_from_args(query, "suggested_only", default=False)
1387+
max_rooms_per_space = parse_integer_from_args(query, "max_rooms_per_space")
1388+
1389+
exclude_rooms = []
1390+
if b"exclude_rooms" in query:
1391+
try:
1392+
exclude_rooms = [
1393+
room_id.decode("ascii") for room_id in query[b"exclude_rooms"]
1394+
]
1395+
except Exception:
1396+
raise SynapseError(
1397+
400, "Bad query parameter for exclude_rooms", Codes.INVALID_PARAM
1398+
)
1399+
1400+
return 200, await self.handler.federation_space_summary(
1401+
room_id, suggested_only, max_rooms_per_space, exclude_rooms
1402+
)
1403+
1404+
# TODO When switching to the stable endpoint, remove the POST handler.
13791405
async def on_POST(
13801406
self,
13811407
origin: str,

synapse/rest/client/v1/room.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ async def on_GET(
10201020
max_rooms_per_space=parse_integer(request, "max_rooms_per_space"),
10211021
)
10221022

1023+
# TODO When switching to the stable endpoint, remove the POST handler.
10231024
async def on_POST(
10241025
self, request: SynapseRequest, room_id: str
10251026
) -> Tuple[int, JsonDict]:

0 commit comments

Comments
 (0)