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

Commit bebf994

Browse files
authored
Move MSC2654 support behind an experimental configuration flag. (#12295)
To match the current thinking on disabling experimental features by default.
1 parent 6927d87 commit bebf994

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

changelog.d/12295.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Move [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654) support behind an experimental configuration flag.

synapse/config/experimental.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ def read_config(self, config: JsonDict, **kwargs):
7878

7979
# The deprecated groups feature.
8080
self.groups_enabled: bool = experimental.get("groups_enabled", True)
81+
82+
# MSC2654: Unread counts
83+
self.msc2654_enabled: bool = experimental.get("msc2654_enabled", False)

synapse/rest/client/sync.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def __init__(self, hs: "HomeServer"):
9999
self.presence_handler = hs.get_presence_handler()
100100
self._server_notices_sender = hs.get_server_notices_sender()
101101
self._event_serializer = hs.get_event_client_serializer()
102+
self._msc2654_enabled = hs.config.experimental.msc2654_enabled
102103

103104
async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
104105
# This will always be set by the time Twisted calls us.
@@ -521,7 +522,8 @@ async def encode_room(
521522
result["ephemeral"] = {"events": ephemeral_events}
522523
result["unread_notifications"] = room.unread_notifications
523524
result["summary"] = room.summary
524-
result["org.matrix.msc2654.unread_count"] = room.unread_count
525+
if self._msc2654_enabled:
526+
result["org.matrix.msc2654.unread_count"] = room.unread_count
525527

526528
return result
527529

tests/rest/client/test_sync.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ class UnreadMessagesTestCase(unittest.HomeserverTestCase):
496496
receipts.register_servlets,
497497
]
498498

499+
def default_config(self) -> JsonDict:
500+
config = super().default_config()
501+
config["experimental_features"] = {"msc2654_enabled": True}
502+
return config
503+
499504
def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
500505
self.url = "/sync?since=%s"
501506
self.next_batch = "s0"

0 commit comments

Comments
 (0)