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

Move MSC2654 support behind an experimental configuration flag. #12295

Merged
merged 3 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12295.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move MSC2654 support behind an experimental configuration flag.
clokep marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,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)
4 changes: 3 additions & 1 deletion synapse/rest/client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions tests/rest/client/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down