Skip to content
Snippets Groups Projects
Unverified Commit f4833e0c authored by Patrick Cloke's avatar Patrick Cloke Committed by GitHub
Browse files

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.
parent 28c68411
No related branches found
No related tags found
No related merge requests found
Update support for [MSC2946](https://github.com/matrix-org/matrix-doc/pull/2946): Spaces Summary.
...@@ -995,6 +995,7 @@ class TransportLayerClient: ...@@ -995,6 +995,7 @@ class TransportLayerClient:
returned per space returned per space
exclude_rooms: a list of any rooms we can skip exclude_rooms: a list of any rooms we can skip
""" """
# TODO When switching to the stable endpoint, use GET instead of POST.
path = _create_path( path = _create_path(
FEDERATION_UNSTABLE_PREFIX, "/org.matrix.msc2946/spaces/%s", room_id FEDERATION_UNSTABLE_PREFIX, "/org.matrix.msc2946/spaces/%s", room_id
) )
......
...@@ -1376,6 +1376,32 @@ class FederationSpaceSummaryServlet(BaseFederationServlet): ...@@ -1376,6 +1376,32 @@ class FederationSpaceSummaryServlet(BaseFederationServlet):
PREFIX = FEDERATION_UNSTABLE_PREFIX + "/org.matrix.msc2946" PREFIX = FEDERATION_UNSTABLE_PREFIX + "/org.matrix.msc2946"
PATH = "/spaces/(?P<room_id>[^/]*)" PATH = "/spaces/(?P<room_id>[^/]*)"
async def on_GET(
self,
origin: str,
content: JsonDict,
query: Mapping[bytes, Sequence[bytes]],
room_id: str,
) -> Tuple[int, JsonDict]:
suggested_only = parse_boolean_from_args(query, "suggested_only", default=False)
max_rooms_per_space = parse_integer_from_args(query, "max_rooms_per_space")
exclude_rooms = []
if b"exclude_rooms" in query:
try:
exclude_rooms = [
room_id.decode("ascii") for room_id in query[b"exclude_rooms"]
]
except Exception:
raise SynapseError(
400, "Bad query parameter for exclude_rooms", Codes.INVALID_PARAM
)
return 200, await self.handler.federation_space_summary(
room_id, suggested_only, max_rooms_per_space, exclude_rooms
)
# TODO When switching to the stable endpoint, remove the POST handler.
async def on_POST( async def on_POST(
self, self,
origin: str, origin: str,
......
...@@ -1020,6 +1020,7 @@ class RoomSpaceSummaryRestServlet(RestServlet): ...@@ -1020,6 +1020,7 @@ class RoomSpaceSummaryRestServlet(RestServlet):
max_rooms_per_space=parse_integer(request, "max_rooms_per_space"), max_rooms_per_space=parse_integer(request, "max_rooms_per_space"),
) )
# TODO When switching to the stable endpoint, remove the POST handler.
async def on_POST( async def on_POST(
self, request: SynapseRequest, room_id: str self, request: SynapseRequest, room_id: str
) -> Tuple[int, JsonDict]: ) -> Tuple[int, JsonDict]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment