mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-07 11:42:15 +00:00
Support the stable dir parameter for /relations. (#13920)
Since MSC3715 has passed FCP, the stable parameter can be used. This currently falls back to the unstable parameter if the stable parameter is not provided (and MSC3715 support is enabled in the configuration).
This commit is contained in:
parent
299b00d968
commit
87fe9db467
1
changelog.d/13920.feature
Normal file
1
changelog.d/13920.feature
Normal file
@ -0,0 +1 @@
|
|||||||
|
Support a `dir` parameter on the `/relations` endpoint per [MSC3715](https://github.com/matrix-org/matrix-doc/pull/3715).
|
@ -56,6 +56,12 @@ class RelationPaginationServlet(RestServlet):
|
|||||||
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
||||||
|
|
||||||
limit = parse_integer(request, "limit", default=5)
|
limit = parse_integer(request, "limit", default=5)
|
||||||
|
# Fetch the direction parameter, if provided.
|
||||||
|
#
|
||||||
|
# TODO Use PaginationConfig.from_request when the unstable parameter is
|
||||||
|
# no longer needed.
|
||||||
|
direction = parse_string(request, "dir", allowed_values=["f", "b"])
|
||||||
|
if direction is None:
|
||||||
if self._msc3715_enabled:
|
if self._msc3715_enabled:
|
||||||
direction = parse_string(
|
direction = parse_string(
|
||||||
request,
|
request,
|
||||||
|
@ -728,7 +728,6 @@ class RelationsTestCase(BaseRelationsTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class RelationPaginationTestCase(BaseRelationsTestCase):
|
class RelationPaginationTestCase(BaseRelationsTestCase):
|
||||||
@unittest.override_config({"experimental_features": {"msc3715_enabled": True}})
|
|
||||||
def test_basic_paginate_relations(self) -> None:
|
def test_basic_paginate_relations(self) -> None:
|
||||||
"""Tests that calling pagination API correctly the latest relations."""
|
"""Tests that calling pagination API correctly the latest relations."""
|
||||||
channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction", "a")
|
channel = self._send_relation(RelationTypes.ANNOTATION, "m.reaction", "a")
|
||||||
@ -771,7 +770,7 @@ class RelationPaginationTestCase(BaseRelationsTestCase):
|
|||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"GET",
|
"GET",
|
||||||
f"/_matrix/client/v1/rooms/{self.room}/relations"
|
f"/_matrix/client/v1/rooms/{self.room}/relations"
|
||||||
f"/{self.parent_id}?limit=1&org.matrix.msc3715.dir=f",
|
f"/{self.parent_id}?limit=1&dir=f",
|
||||||
access_token=self.user_token,
|
access_token=self.user_token,
|
||||||
)
|
)
|
||||||
self.assertEqual(200, channel.code, channel.json_body)
|
self.assertEqual(200, channel.code, channel.json_body)
|
||||||
@ -788,7 +787,6 @@ class RelationPaginationTestCase(BaseRelationsTestCase):
|
|||||||
channel.json_body["chunk"][0],
|
channel.json_body["chunk"][0],
|
||||||
)
|
)
|
||||||
|
|
||||||
@unittest.override_config({"experimental_features": {"msc3715_enabled": True}})
|
|
||||||
def test_repeated_paginate_relations(self) -> None:
|
def test_repeated_paginate_relations(self) -> None:
|
||||||
"""Test that if we paginate using a limit and tokens then we get the
|
"""Test that if we paginate using a limit and tokens then we get the
|
||||||
expected events.
|
expected events.
|
||||||
@ -838,7 +836,7 @@ class RelationPaginationTestCase(BaseRelationsTestCase):
|
|||||||
|
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"GET",
|
"GET",
|
||||||
f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}?org.matrix.msc3715.dir=f&limit=3{from_token}",
|
f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}?dir=f&limit=3{from_token}",
|
||||||
access_token=self.user_token,
|
access_token=self.user_token,
|
||||||
)
|
)
|
||||||
self.assertEqual(200, channel.code, channel.json_body)
|
self.assertEqual(200, channel.code, channel.json_body)
|
||||||
|
Loading…
Reference in New Issue
Block a user