From b362a235b4fe0a5824f190b02556382baaca9207 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 22 Mar 2024 15:56:42 -0400 Subject: [PATCH 1/5] Stabliize support for MSC3981. --- synapse/config/experimental.py | 5 ----- synapse/rest/client/relations.py | 9 +++------ synapse/rest/client/versions.py | 3 ++- tests/rest/client/test_relations.py | 8 +++----- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index 0bd3befdc2e..cc0c91a1756 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -393,11 +393,6 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: # MSC3967: Do not require UIA when first uploading cross signing keys self.msc3967_enabled = experimental.get("msc3967_enabled", False) - # MSC3981: Recurse relations - self.msc3981_recurse_relations = experimental.get( - "msc3981_recurse_relations", False - ) - # MSC3861: Matrix architecture change to delegate authentication via OIDC try: self.msc3861 = MSC3861(**experimental.get("msc3861", {})) diff --git a/synapse/rest/client/relations.py b/synapse/rest/client/relations.py index 42da017f375..e6a08ec13ee 100644 --- a/synapse/rest/client/relations.py +++ b/synapse/rest/client/relations.py @@ -70,12 +70,9 @@ async def on_GET( pagination_config = await PaginationConfig.from_request( self._store, request, default_limit=5, default_dir=Direction.BACKWARDS ) - if self._support_recurse: - recurse = parse_boolean(request, "recurse", default=False) or parse_boolean( - request, "org.matrix.msc3981.recurse", default=False - ) - else: - recurse = False + recurse = parse_boolean(request, "recurse", default=False) or parse_boolean( + request, "org.matrix.msc3981.recurse", default=False + ) # The unstable version of this API returns an extra field for client # compatibility, see https://github.com/matrix-org/synapse/issues/12930. diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index 32db274f32b..c46d4fe8cf3 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -132,7 +132,8 @@ def on_GET(self, request: Request) -> Tuple[int, JsonDict]: # Adds support for relation-based redactions as per MSC3912. "org.matrix.msc3912": self.config.experimental.msc3912_enabled, # Whether recursively provide relations is supported. - "org.matrix.msc3981": self.config.experimental.msc3981_recurse_relations, + # TODO This is no longer needed once unstable MSC3981 does not need to be supported. + "org.matrix.msc3981": True, # Adds support for deleting account data. "org.matrix.msc3391": self.config.experimental.msc3391_enabled, # Allows clients to inhibit profile update propagation. diff --git a/tests/rest/client/test_relations.py b/tests/rest/client/test_relations.py index c05b3fc781c..f4b7f66d9e4 100644 --- a/tests/rest/client/test_relations.py +++ b/tests/rest/client/test_relations.py @@ -957,7 +957,6 @@ def test_pagination_from_sync_and_messages(self) -> None: class RecursiveRelationTestCase(BaseRelationsTestCase): - @override_config({"experimental_features": {"msc3981_recurse_relations": True}}) def test_recursive_relations(self) -> None: """Generate a complex, multi-level relationship tree and query it.""" # Create a thread with a few messages in it. @@ -1003,7 +1002,7 @@ def test_recursive_relations(self) -> None: channel = self.make_request( "GET", f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}" - "?dir=f&limit=20&org.matrix.msc3981.recurse=true", + "?dir=f&limit=20&recurse=true", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) @@ -1024,7 +1023,6 @@ def test_recursive_relations(self) -> None: ], ) - @override_config({"experimental_features": {"msc3981_recurse_relations": True}}) def test_recursive_relations_with_filter(self) -> None: """The event_type and rel_type still apply.""" # Create a thread with a few messages in it. @@ -1052,7 +1050,7 @@ def test_recursive_relations_with_filter(self) -> None: channel = self.make_request( "GET", f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}/{RelationTypes.ANNOTATION}" - "?dir=f&limit=20&org.matrix.msc3981.recurse=true", + "?dir=f&limit=20&recurse=true", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) @@ -1065,7 +1063,7 @@ def test_recursive_relations_with_filter(self) -> None: channel = self.make_request( "GET", f"/_matrix/client/v1/rooms/{self.room}/relations/{self.parent_id}/{RelationTypes.ANNOTATION}/m.reaction" - "?dir=f&limit=20&org.matrix.msc3981.recurse=true", + "?dir=f&limit=20&recurse=true", access_token=self.user_token, ) self.assertEqual(200, channel.code, channel.json_body) From 2b8bb409a5f3d2539fee721e5e85051ceed1fe11 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 22 Mar 2024 15:59:38 -0400 Subject: [PATCH 2/5] Newsfragment --- changelog.d/17023.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17023.feature diff --git a/changelog.d/17023.feature b/changelog.d/17023.feature new file mode 100644 index 00000000000..7cec681a464 --- /dev/null +++ b/changelog.d/17023.feature @@ -0,0 +1 @@ +Stabilize support for [MSC3981](https://github.com/matrix-org/matrix-spec-proposals/pull/3981): `/relations` recursion. From a71054dbed920d2bdbd593207f850a37e4a8c1a7 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 3 Apr 2024 08:16:55 -0400 Subject: [PATCH 3/5] Unused import --- tests/rest/client/test_relations.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/rest/client/test_relations.py b/tests/rest/client/test_relations.py index f4b7f66d9e4..f5a7602d0a5 100644 --- a/tests/rest/client/test_relations.py +++ b/tests/rest/client/test_relations.py @@ -35,7 +35,6 @@ from tests import unittest from tests.server import FakeChannel from tests.test_utils.event_injection import inject_event -from tests.unittest import override_config class BaseRelationsTestCase(unittest.HomeserverTestCase): From 2b552a801005adf5d54ba787f091b1bbe8296784 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 3 Apr 2024 08:18:06 -0400 Subject: [PATCH 4/5] Update 17023.feature --- changelog.d/17023.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/17023.feature b/changelog.d/17023.feature index 7cec681a464..af772374fec 100644 --- a/changelog.d/17023.feature +++ b/changelog.d/17023.feature @@ -1 +1 @@ -Stabilize support for [MSC3981](https://github.com/matrix-org/matrix-spec-proposals/pull/3981): `/relations` recursion. +Stabilize support for [MSC3981](https://github.com/matrix-org/matrix-spec-proposals/pull/3981): `/relations` recursion. Contributed by @clokep. \ No newline at end of file From a0f9ce61c643645229686cce9670951f2ef42748 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 3 Apr 2024 08:18:54 -0400 Subject: [PATCH 5/5] Remove reference to removed property. --- synapse/rest/client/relations.py | 1 - 1 file changed, 1 deletion(-) diff --git a/synapse/rest/client/relations.py b/synapse/rest/client/relations.py index e6a08ec13ee..49943cf0c34 100644 --- a/synapse/rest/client/relations.py +++ b/synapse/rest/client/relations.py @@ -55,7 +55,6 @@ def __init__(self, hs: "HomeServer"): self.auth = hs.get_auth() self._store = hs.get_datastores().main self._relations_handler = hs.get_relations_handler() - self._support_recurse = hs.config.experimental.msc3981_recurse_relations async def on_GET( self,