From 933b9530d9867e8cc5e59b7062a4023a3eb2560f Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 6 Apr 2022 15:20:34 -0400 Subject: [PATCH 1/2] Support the v1 endpoint for /relations. --- synapse/rest/client/relations.py | 2 +- tests/rest/client/test_relations.py | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/synapse/rest/client/relations.py b/synapse/rest/client/relations.py index 55c96a2af3d9..3cae6d2b556e 100644 --- a/synapse/rest/client/relations.py +++ b/synapse/rest/client/relations.py @@ -35,7 +35,7 @@ class RelationPaginationServlet(RestServlet): PATTERNS = client_patterns( "/rooms/(?P[^/]*)/relations/(?P[^/]*)" "(/(?P[^/]*)(/(?P[^/]*))?)?$", - releases=(), + releases=("v1",), ) def __init__(self, hs: "HomeServer"): diff --git a/tests/rest/client/test_relations.py b/tests/rest/client/test_relations.py index 419eef166ac4..2f2ec3a685eb 100644 --- a/tests/rest/client/test_relations.py +++ b/tests/rest/client/test_relations.py @@ -125,7 +125,7 @@ def _get_related_events(self) -> List[str]: # Request the relations of the event. channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}", + f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}", access_token=self.user_token, ) self.assertEquals(200, channel.code, channel.json_body) @@ -138,7 +138,7 @@ def _get_bundled_aggregations(self) -> JsonDict: # Fetch the bundled aggregations of the event. channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/event/{self.parent_id}", + f"/_matrix/client/v3/rooms/{self.room}/event/{self.parent_id}", access_token=self.user_token, ) self.assertEquals(200, channel.code, channel.json_body) @@ -340,7 +340,7 @@ def test_ignore_invalid_room(self) -> None: # They should be ignored when fetching relations. channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{room2}/relations/{parent_id}", + f"/_matrix/client/v1/rooms/{room2}/relations/{parent_id}", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) @@ -633,7 +633,7 @@ def test_unknown_relations(self) -> None: channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}?limit=1", + f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}?limit=1", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) @@ -685,7 +685,7 @@ def test_background_update(self) -> None: # Only the "good" annotation should be found. channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}?limit=10", + f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}?limit=10", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) @@ -710,7 +710,7 @@ def test_background_update(self) -> None: # annotation. channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}?limit=10", + f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}?limit=10", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) @@ -731,7 +731,7 @@ def test_basic_paginate_relations(self) -> None: channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}?limit=1", + f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}?limit=1", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) @@ -762,7 +762,7 @@ def test_basic_paginate_relations(self) -> None: # Request the relations again, but with a different direction. channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/relations" + f"/_matrix/client/v1/rooms/{self.room}/relations" f"/{self.parent_id}?limit=1&org.matrix.msc3715.dir=f", access_token=self.user_token, ) @@ -801,7 +801,7 @@ def test_repeated_paginate_relations(self) -> None: channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}?limit=1{from_token}", + f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}?limit=1{from_token}", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) @@ -865,7 +865,7 @@ def test_pagination_from_sync_and_messages(self) -> None: for from_token in (sync_prev_batch, messages_end): channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}?from={from_token}", + f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}?from={from_token}", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) @@ -1088,7 +1088,7 @@ def test_aggregation_get_event_for_thread(self) -> None: # It should also be included when the entire thread is requested. channel = self.make_request( "GET", - f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}?limit=1", + f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}?limit=1", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) From 8b7e088f0b8784bbc3901411ba2a059b333d58e9 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 6 Apr 2022 15:22:09 -0400 Subject: [PATCH 2/2] Newsfragment --- changelog.d/12403.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12403.feature diff --git a/changelog.d/12403.feature b/changelog.d/12403.feature new file mode 100644 index 000000000000..5b55e86ecb46 --- /dev/null +++ b/changelog.d/12403.feature @@ -0,0 +1 @@ +Support the stable `v1` endpoint for `/relations`, per [MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675).