summary refs log tree commit diff
path: root/synapse/rest/client
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2022-10-07 09:26:40 -0400
committerGitHub <noreply@github.com>2022-10-07 09:26:40 -0400
commit66a785733458d0b5801097caff53624e202a91b4 (patch)
treeef211ad0fefd409961a03cd0ec8a0fd5b0a5e951 /synapse/rest/client
parentAdd sample worker files for `pusher` and `federation_sender` (#14077) (diff)
downloadsynapse-66a785733458d0b5801097caff53624e202a91b4.tar.xz
Use stable identifiers for MSC3771 & MSC3773. (#14050)
These are both part of Matrix 1.4 which has now been released.

For now, support both the unstable and stable identifiers.
Diffstat (limited to 'synapse/rest/client')
-rw-r--r--synapse/rest/client/receipts.py48
-rw-r--r--synapse/rest/client/sync.py9
-rw-r--r--synapse/rest/client/versions.py2
3 files changed, 30 insertions, 29 deletions
diff --git a/synapse/rest/client/receipts.py b/synapse/rest/client/receipts.py
index 287dfdd69e..14dec7ac4e 100644
--- a/synapse/rest/client/receipts.py
+++ b/synapse/rest/client/receipts.py
@@ -50,7 +50,6 @@ class ReceiptRestServlet(RestServlet):
             ReceiptTypes.READ_PRIVATE,
             ReceiptTypes.FULLY_READ,
         }
-        self._msc3771_enabled = hs.config.experimental.msc3771_enabled
 
     async def on_POST(
         self, request: SynapseRequest, room_id: str, receipt_type: str, event_id: str
@@ -67,30 +66,29 @@ class ReceiptRestServlet(RestServlet):
 
         # Pull the thread ID, if one exists.
         thread_id = None
-        if self._msc3771_enabled:
-            if "thread_id" in body:
-                thread_id = body.get("thread_id")
-                if not thread_id or not isinstance(thread_id, str):
-                    raise SynapseError(
-                        400,
-                        "thread_id field must be a non-empty string",
-                        Codes.INVALID_PARAM,
-                    )
-
-                if receipt_type == ReceiptTypes.FULLY_READ:
-                    raise SynapseError(
-                        400,
-                        f"thread_id is not compatible with {ReceiptTypes.FULLY_READ} receipts.",
-                        Codes.INVALID_PARAM,
-                    )
-
-                # Ensure the event ID roughly correlates to the thread ID.
-                if thread_id != await self._main_store.get_thread_id(event_id):
-                    raise SynapseError(
-                        400,
-                        f"event_id {event_id} is not related to thread {thread_id}",
-                        Codes.INVALID_PARAM,
-                    )
+        if "thread_id" in body:
+            thread_id = body.get("thread_id")
+            if not thread_id or not isinstance(thread_id, str):
+                raise SynapseError(
+                    400,
+                    "thread_id field must be a non-empty string",
+                    Codes.INVALID_PARAM,
+                )
+
+            if receipt_type == ReceiptTypes.FULLY_READ:
+                raise SynapseError(
+                    400,
+                    f"thread_id is not compatible with {ReceiptTypes.FULLY_READ} receipts.",
+                    Codes.INVALID_PARAM,
+                )
+
+            # Ensure the event ID roughly correlates to the thread ID.
+            if thread_id != await self._main_store.get_thread_id(event_id):
+                raise SynapseError(
+                    400,
+                    f"event_id {event_id} is not related to thread {thread_id}",
+                    Codes.INVALID_PARAM,
+                )
 
         await self.presence_handler.bump_presence_active_time(requester.user)
 
diff --git a/synapse/rest/client/sync.py b/synapse/rest/client/sync.py
index f1c23d68e5..8a16459105 100644
--- a/synapse/rest/client/sync.py
+++ b/synapse/rest/client/sync.py
@@ -100,6 +100,7 @@ class SyncRestServlet(RestServlet):
         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
+        self._msc3773_enabled = hs.config.experimental.msc3773_enabled
 
     async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
         # This will always be set by the time Twisted calls us.
@@ -510,9 +511,11 @@ class SyncRestServlet(RestServlet):
             result["ephemeral"] = {"events": ephemeral_events}
             result["unread_notifications"] = room.unread_notifications
             if room.unread_thread_notifications:
-                result[
-                    "org.matrix.msc3773.unread_thread_notifications"
-                ] = room.unread_thread_notifications
+                result["unread_thread_notifications"] = room.unread_thread_notifications
+                if self._msc3773_enabled:
+                    result[
+                        "org.matrix.msc3773.unread_thread_notifications"
+                    ] = room.unread_thread_notifications
             result["summary"] = room.summary
             if self._msc2654_enabled:
                 result["org.matrix.msc2654.unread_count"] = room.unread_count
diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py
index 18ed313b5c..d1d2e5f7e3 100644
--- a/synapse/rest/client/versions.py
+++ b/synapse/rest/client/versions.py
@@ -105,7 +105,7 @@ class VersionsRestServlet(RestServlet):
                     # Adds support for thread relations, per MSC3440.
                     "org.matrix.msc3440.stable": True,  # TODO: remove when "v1.3" is added above
                     # Support for thread read receipts & notification counts.
-                    "org.matrix.msc3771": self.config.experimental.msc3771_enabled,
+                    "org.matrix.msc3771": True,
                     "org.matrix.msc3773": self.config.experimental.msc3773_enabled,
                     # Allows moderators to fetch redacted event content as described in MSC2815
                     "fi.mau.msc2815": self.config.experimental.msc2815_enabled,