From 6bea0f26398cfe72726497500db31a8d11793f23 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Tue, 1 Oct 2024 12:26:28 -0400 Subject: [PATCH 1/3] Don't say MSC4140 is supported when it's disabled --- synapse/rest/client/versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index 1cfac876064..8028cf8ad2c 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -172,7 +172,7 @@ async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]: ) ), # MSC4140: Delayed events - "org.matrix.msc4140": True, + "org.matrix.msc4140": bool(self.config.server.max_event_delay_ms), # MSC4151: Report room API (Client-Server API) "org.matrix.msc4151": self.config.experimental.msc4151_enabled, # Simplified sliding sync From 1ec244b42f516c59007cc7e42258739867a92147 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Wed, 2 Oct 2024 19:29:51 -0400 Subject: [PATCH 2/3] Add test coverage --- tests/rest/client/test_delayed_events.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/rest/client/test_delayed_events.py b/tests/rest/client/test_delayed_events.py index 34d9fe79587..cb77c73da24 100644 --- a/tests/rest/client/test_delayed_events.py +++ b/tests/rest/client/test_delayed_events.py @@ -8,11 +8,12 @@ from twisted.test.proto_helpers import MemoryReactor from synapse.api.errors import Codes -from synapse.rest.client import delayed_events, room +from synapse.rest.client import delayed_events, room, versions from synapse.server import HomeServer from synapse.types import JsonDict from synapse.util import Clock +from tests import unittest from tests.unittest import HomeserverTestCase PATH_PREFIX = "/_matrix/client/unstable/org.matrix.msc4140/delayed_events" @@ -21,6 +22,21 @@ _EVENT_TYPE = "com.example.test" +class DelayedEventsUnstableSupportTestCase(HomeserverTestCase): + servlets = [versions.register_servlets] + + def test_false_by_default(self) -> None: + channel = self.make_request("GET", "/_matrix/client/versions") + self.assertEqual(channel.code, 200, channel.result) + self.assertFalse(channel.json_body["unstable_features"]["org.matrix.msc4140"]) + + @unittest.override_config({"max_event_delay_duration": "24h"}) + def test_true_if_enabled(self) -> None: + channel = self.make_request("GET", "/_matrix/client/versions") + self.assertEqual(channel.code, 200, channel.result) + self.assertTrue(channel.json_body["unstable_features"]["org.matrix.msc4140"]) + + class DelayedEventsTestCase(HomeserverTestCase): """Tests getting and managing delayed events.""" From 59ca2ee3233b3a9ecf6e1d176660a4644d4e099e Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Thu, 3 Oct 2024 00:07:03 -0400 Subject: [PATCH 3/3] Add changelog --- changelog.d/17780.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17780.bugfix diff --git a/changelog.d/17780.bugfix b/changelog.d/17780.bugfix new file mode 100644 index 00000000000..9d918ae745e --- /dev/null +++ b/changelog.d/17780.bugfix @@ -0,0 +1 @@ +In the response to `GET /_matrix/client/versions`, set the `unstable_features` flag for MSC4140 to `false` when server configuration disables support for delayed events.