From 0cbddc632eebd0c24fcfa4786edae93202421306 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 28 Jul 2022 15:41:00 -0400 Subject: Add an experimental config flag. --- synapse/config/experimental.py | 2 ++ synapse/rest/client/receipts.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index 0c28182799..9a244e0bc6 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -82,6 +82,8 @@ class ExperimentalConfig(Config): # MSC3786 (Add a default push rule to ignore m.room.server_acl events) self.msc3786_enabled: bool = experimental.get("msc3786_enabled", False) + # MSC3771: Thread read receipts + self.msc3771_enabled: bool = experimental.get("msc3771_enabled", False) # MSC3772: A push rule for mutual relations. self.msc3772_enabled: bool = experimental.get("msc3772_enabled", False) # MSC3773: Thread notifications diff --git a/synapse/rest/client/receipts.py b/synapse/rest/client/receipts.py index 3e4aea065a..15d98a6226 100644 --- a/synapse/rest/client/receipts.py +++ b/synapse/rest/client/receipts.py @@ -16,7 +16,7 @@ import logging from typing import TYPE_CHECKING, Optional, Tuple from synapse.api.constants import ReceiptTypes -from synapse.api.errors import SynapseError +from synapse.api.errors import SynapseError, UnrecognizedRequestError from synapse.http.server import HttpServer from synapse.http.servlet import RestServlet, parse_json_object_from_request from synapse.http.site import SynapseRequest @@ -51,6 +51,8 @@ class ReceiptRestServlet(RestServlet): (ReceiptTypes.READ_PRIVATE, ReceiptTypes.FULLY_READ) ) + self._msc3771_enabled = hs.config.experimental.msc3771_enabled + async def on_POST( self, request: SynapseRequest, @@ -67,6 +69,9 @@ class ReceiptRestServlet(RestServlet): f"Receipt type must be {', '.join(self._known_receipt_types)}", ) + if thread_id and not self._msc3771_enabled: + raise UnrecognizedRequestError() + parse_json_object_from_request(request, allow_empty_body=False) await self.presence_handler.bump_presence_active_time(requester.user) -- cgit 1.4.1