From 5c9ebc2ed379cf42d767057a6ea4ff9bde503369 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 24 Mar 2022 14:33:46 -0400 Subject: [PATCH 1/2] Move MSC2654 support behind an experimental configuration flag. --- changelog.d/12295.misc | 1 + synapse/config/experimental.py | 3 +++ synapse/rest/client/sync.py | 4 +++- tests/rest/client/test_sync.py | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changelog.d/12295.misc diff --git a/changelog.d/12295.misc b/changelog.d/12295.misc new file mode 100644 index 000000000000..cfd43b1db7ec --- /dev/null +++ b/changelog.d/12295.misc @@ -0,0 +1 @@ +Move MSC2654 support behind an experimental configuration flag. diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index 064db4487c85..273bfa9fb43c 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -77,3 +77,6 @@ def read_config(self, config: JsonDict, **kwargs): # The deprecated groups feature. self.groups_enabled: bool = experimental.get("groups_enabled", True) + + # MSC2654: Unread counts + self.msc2654_enabled: bool = experimental.get("msc2654_enabled", False) diff --git a/synapse/rest/client/sync.py b/synapse/rest/client/sync.py index 53c385a86cc1..0bf32f873be7 100644 --- a/synapse/rest/client/sync.py +++ b/synapse/rest/client/sync.py @@ -99,6 +99,7 @@ def __init__(self, hs: "HomeServer"): self.presence_handler = hs.get_presence_handler() self._server_notices_sender = hs.get_server_notices_sender() self._event_serializer = hs.get_event_client_serializer() + self._msc2654_enabled = hs.config.experimental.msc2654_enabled async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]: # This will always be set by the time Twisted calls us. @@ -521,7 +522,8 @@ async def encode_room( result["ephemeral"] = {"events": ephemeral_events} result["unread_notifications"] = room.unread_notifications result["summary"] = room.summary - result["org.matrix.msc2654.unread_count"] = room.unread_count + if self._msc2654_enabled: + result["org.matrix.msc2654.unread_count"] = room.unread_count return result diff --git a/tests/rest/client/test_sync.py b/tests/rest/client/test_sync.py index 435101395204..e7f0bae90268 100644 --- a/tests/rest/client/test_sync.py +++ b/tests/rest/client/test_sync.py @@ -497,6 +497,11 @@ class UnreadMessagesTestCase(unittest.HomeserverTestCase): receipts.register_servlets, ] + def default_config(self) -> JsonDict: + config = super().default_config() + config["experimental_features"] = {"msc2654_enabled": True} + return config + def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: self.url = "/sync?since=%s" self.next_batch = "s0" From 66c37a9adda869d9ad00c52a5609916fe98e7aae Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 30 Mar 2022 10:03:21 -0400 Subject: [PATCH 2/2] Link to MSC in changelog. --- changelog.d/12295.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/12295.misc b/changelog.d/12295.misc index cfd43b1db7ec..9c34e169096c 100644 --- a/changelog.d/12295.misc +++ b/changelog.d/12295.misc @@ -1 +1 @@ -Move MSC2654 support behind an experimental configuration flag. +Move [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654) support behind an experimental configuration flag.