From b01d7653043e7c779ddb1dceaf8e356faf132c34 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 3 Mar 2022 11:02:37 -0500 Subject: [PATCH] Remove experimental config flag. --- synapse/api/filtering.py | 25 ++++------ synapse/config/experimental.py | 2 - synapse/rest/client/versions.py | 2 +- synapse/storage/databases/main/relations.py | 55 +++++++-------------- tests/rest/client/test_relations.py | 7 +-- 5 files changed, 29 insertions(+), 62 deletions(-) diff --git a/synapse/api/filtering.py b/synapse/api/filtering.py index 8189796058a3..e86c830a32a6 100644 --- a/synapse/api/filtering.py +++ b/synapse/api/filtering.py @@ -320,22 +320,15 @@ def __init__(self, hs: "HomeServer", filter_json: JsonDict): self.labels = filter_json.get("org.matrix.labels", None) self.not_labels = filter_json.get("org.matrix.not_labels", []) - # Ideally these would be rejected at the endpoint if they were provided - # and not supported, but that would involve modifying the JSON schema - # based on the homeserver configuration. - if hs.config.experimental.msc3440_enabled: - # Fallback to the unstable prefix if the stable version is not given. - self.related_by_senders = self.filter_json.get( - "related_by_senders", - self.filter_json.get("io.element.relation_senders", None), - ) - self.related_by_rel_types = self.filter_json.get( - "related_by_rel_types", - self.filter_json.get("io.element.relation_types", None), - ) - else: - self.related_by_senders = None - self.related_by_rel_types = None + # Fallback to the unstable prefix if the stable version is not given. + self.related_by_senders = self.filter_json.get( + "related_by_senders", + self.filter_json.get("io.element.relation_senders", None), + ) + self.related_by_rel_types = self.filter_json.get( + "related_by_rel_types", + self.filter_json.get("io.element.relation_types", None), + ) def filters_all_types(self) -> bool: return "*" in self.not_types diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index 41338b39df21..d8694d12b6f7 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -24,8 +24,6 @@ class ExperimentalConfig(Config): def read_config(self, config: JsonDict, **kwargs): experimental = config.get("experimental_features") or {} - # MSC3440 (thread relation) - self.msc3440_enabled: bool = experimental.get("msc3440_enabled", False) # MSC3666: including bundled relations in /search. self.msc3666_enabled: bool = experimental.get("msc3666_enabled", False) diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index 2e5d0e4e2258..8aaa6efa774d 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -100,7 +100,7 @@ def on_GET(self, request: Request) -> Tuple[int, JsonDict]: # Adds support for jump to date endpoints (/timestamp_to_event) as per MSC3030 "org.matrix.msc3030": self.config.experimental.msc3030_enabled, # Adds support for thread relations, per MSC3440. - "org.matrix.msc3440": self.config.experimental.msc3440_enabled, + "org.matrix.msc3440": True, }, }, ) diff --git a/synapse/storage/databases/main/relations.py b/synapse/storage/databases/main/relations.py index 0ce2bb66fc22..36725f8c7d92 100644 --- a/synapse/storage/databases/main/relations.py +++ b/synapse/storage/databases/main/relations.py @@ -32,12 +32,7 @@ from synapse.api.constants import RelationTypes from synapse.events import EventBase from synapse.storage._base import SQLBaseStore -from synapse.storage.database import ( - DatabasePool, - LoggingDatabaseConnection, - LoggingTransaction, - make_in_list_sql_clause, -) +from synapse.storage.database import LoggingTransaction, make_in_list_sql_clause from synapse.storage.databases.main.stream import generate_pagination_where_clause from synapse.storage.engines import PostgresEngine from synapse.storage.relations import AggregationPaginationToken, PaginationChunk @@ -45,7 +40,6 @@ from synapse.util.caches.descriptors import cached, cachedList if TYPE_CHECKING: - from synapse.server import HomeServer from synapse.storage.databases.main import DataStore logger = logging.getLogger(__name__) @@ -81,16 +75,6 @@ def __bool__(self) -> bool: class RelationsWorkerStore(SQLBaseStore): - def __init__( - self, - database: DatabasePool, - db_conn: LoggingDatabaseConnection, - hs: "HomeServer", - ): - super().__init__(database, db_conn, hs) - - self._msc3440_enabled = hs.config.experimental.msc3440_enabled - @cached(tree=True) async def get_relations_for_event( self, @@ -832,26 +816,23 @@ async def get_bundled_aggregations( results.setdefault(event_id, BundledAggregations()).replace = edit # Fetch thread summaries. - if self._msc3440_enabled: - summaries = await self._get_thread_summaries(seen_event_ids) - # Only fetch participated for a limited selection based on what had - # summaries. - participated = await self._get_threads_participated( - summaries.keys(), user_id - ) - for event_id, summary in summaries.items(): - if summary: - thread_count, latest_thread_event, edit = summary - results.setdefault( - event_id, BundledAggregations() - ).thread = _ThreadAggregation( - latest_event=latest_thread_event, - latest_edit=edit, - count=thread_count, - # If there's a thread summary it must also exist in the - # participated dictionary. - current_user_participated=participated[event_id], - ) + summaries = await self._get_thread_summaries(seen_event_ids) + # Only fetch participated for a limited selection based on what had + # summaries. + participated = await self._get_threads_participated(summaries.keys(), user_id) + for event_id, summary in summaries.items(): + if summary: + thread_count, latest_thread_event, edit = summary + results.setdefault( + event_id, BundledAggregations() + ).thread = _ThreadAggregation( + latest_event=latest_thread_event, + latest_edit=edit, + count=thread_count, + # If there's a thread summary it must also exist in the + # participated dictionary. + current_user_participated=participated[event_id], + ) return results diff --git a/tests/rest/client/test_relations.py b/tests/rest/client/test_relations.py index ac3243c4591b..7a759a29a0b4 100644 --- a/tests/rest/client/test_relations.py +++ b/tests/rest/client/test_relations.py @@ -547,9 +547,7 @@ def test_aggregation_must_be_annotation(self) -> None: ) self.assertEqual(400, channel.code, channel.json_body) - @unittest.override_config( - {"experimental_features": {"msc3440_enabled": True, "msc3666_enabled": True}} - ) + @unittest.override_config({"experimental_features": {"msc3666_enabled": True}}) def test_bundled_aggregations(self) -> None: """ Test that annotations, references, and threads get correctly bundled. @@ -759,7 +757,6 @@ def test_aggregation_get_event_for_thread(self) -> None: }, ) - @unittest.override_config({"experimental_features": {"msc3440_enabled": True}}) def test_ignore_invalid_room(self) -> None: """Test that we ignore invalid relations over federation.""" # Create another room and send a message in it. @@ -1066,7 +1063,6 @@ def test_edit_reply(self) -> None: {"event_id": edit_event_id, "sender": self.user_id}, m_replace_dict ) - @unittest.override_config({"experimental_features": {"msc3440_enabled": True}}) def test_edit_thread(self) -> None: """Test that editing a thread works.""" @@ -1384,7 +1380,6 @@ def test_redact_relation_annotation(self) -> None: chunk = self._get_aggregations() self.assertEqual(chunk, [{"type": "m.reaction", "key": "a", "count": 1}]) - @unittest.override_config({"experimental_features": {"msc3440_enabled": True}}) def test_redact_relation_thread(self) -> None: """ Test that thread replies are properly handled after the thread reply redacted.