summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2022-03-31 15:05:13 -0400
committerGitHub <noreply@github.com>2022-03-31 15:05:13 -0400
commitbebf994ee804ef63ce16801c6694713fcd685320 (patch)
treefd409e3f2f51451a407e372a1abbbb2af68f3c7e
parentHandle outliers in `/federation/v1/event` (#12332) (diff)
downloadsynapse-bebf994ee804ef63ce16801c6694713fcd685320.tar.xz
Move MSC2654 support behind an experimental configuration flag. (#12295)
To match the current thinking on disabling experimental features by default.
-rw-r--r--changelog.d/12295.misc1
-rw-r--r--synapse/config/experimental.py3
-rw-r--r--synapse/rest/client/sync.py4
-rw-r--r--tests/rest/client/test_sync.py5
4 files changed, 12 insertions, 1 deletions
diff --git a/changelog.d/12295.misc b/changelog.d/12295.misc
new file mode 100644
index 0000000000..9c34e16909
--- /dev/null
+++ b/changelog.d/12295.misc
@@ -0,0 +1 @@
+Move [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654) support behind an experimental configuration flag.
diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py
index d6bb1f752b..43db5fcdd9 100644
--- a/synapse/config/experimental.py
+++ b/synapse/config/experimental.py
@@ -78,3 +78,6 @@ class ExperimentalConfig(Config):
 
         # 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 53c385a86c..0bf32f873b 100644
--- a/synapse/rest/client/sync.py
+++ b/synapse/rest/client/sync.py
@@ -99,6 +99,7 @@ class SyncRestServlet(RestServlet):
         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 @@ class SyncRestServlet(RestServlet):
             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 3cebbd18f0..773c16a54c 100644
--- a/tests/rest/client/test_sync.py
+++ b/tests/rest/client/test_sync.py
@@ -496,6 +496,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"