Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabliize support for MSC3981: recurse /relations #17023

Merged
merged 6 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/17023.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stabilize support for [MSC3981](https://github.com/matrix-org/matrix-spec-proposals/pull/3981): `/relations` recursion. Contributed by @clokep.
5 changes: 0 additions & 5 deletions synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {}))
Expand Down
10 changes: 3 additions & 7 deletions synapse/rest/client/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -70,12 +69,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.
Expand Down
3 changes: 2 additions & 1 deletion synapse/rest/client/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 3 additions & 6 deletions tests/rest/client/test_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -957,7 +956,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.
Expand Down Expand Up @@ -1003,7 +1001,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)
Expand All @@ -1024,7 +1022,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.
Expand Down Expand Up @@ -1052,7 +1049,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)
Expand All @@ -1065,7 +1062,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)
Expand Down
Loading