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

Commit

Permalink
Support the v1 endpoint for /relations. (#12403)
Browse files Browse the repository at this point in the history
Now that MSC2675 has passed FCP and the implementation is
compliant with the final version.
  • Loading branch information
clokep authored Apr 7, 2022
1 parent 3500626 commit 0bcb651
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions changelog.d/12403.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support the stable `v1` endpoint for `/relations`, per [MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675).
2 changes: 1 addition & 1 deletion synapse/rest/client/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RelationPaginationServlet(RestServlet):
PATTERNS = client_patterns(
"/rooms/(?P<room_id>[^/]*)/relations/(?P<parent_id>[^/]*)"
"(/(?P<relation_type>[^/]*)(/(?P<event_type>[^/]*))?)?$",
releases=(),
releases=("v1",),
)

def __init__(self, hs: "HomeServer"):
Expand Down
22 changes: 11 additions & 11 deletions tests/rest/client/test_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0bcb651

Please sign in to comment.