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

Commit

Permalink
Remove experimental config flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Mar 3, 2022
1 parent 60bc5b8 commit 1e1e540
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 49 deletions.
25 changes: 9 additions & 16 deletions synapse/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
)
Expand Down
49 changes: 19 additions & 30 deletions synapse/storage/databases/main/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,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,
Expand Down Expand Up @@ -832,26 +822,25 @@ 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

Expand Down

0 comments on commit 1e1e540

Please sign in to comment.