Don't say MSC4140 is supported when it's disabled (#17780)

This commit is contained in:
Andrew Ferrazzutti 2024-10-04 08:42:34 -04:00 committed by GitHub
parent 316d635906
commit 9920417723
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

1
changelog.d/17780.bugfix Normal file
View file

@ -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.

View file

@ -172,7 +172,7 @@ class VersionsRestServlet(RestServlet):
) )
), ),
# MSC4140: Delayed events # 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) # MSC4151: Report room API (Client-Server API)
"org.matrix.msc4151": self.config.experimental.msc4151_enabled, "org.matrix.msc4151": self.config.experimental.msc4151_enabled,
# Simplified sliding sync # Simplified sliding sync

View file

@ -8,11 +8,12 @@ from parameterized import parameterized
from twisted.test.proto_helpers import MemoryReactor from twisted.test.proto_helpers import MemoryReactor
from synapse.api.errors import Codes 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.server import HomeServer
from synapse.types import JsonDict from synapse.types import JsonDict
from synapse.util import Clock from synapse.util import Clock
from tests import unittest
from tests.unittest import HomeserverTestCase from tests.unittest import HomeserverTestCase
PATH_PREFIX = "/_matrix/client/unstable/org.matrix.msc4140/delayed_events" PATH_PREFIX = "/_matrix/client/unstable/org.matrix.msc4140/delayed_events"
@ -21,6 +22,21 @@ _HS_NAME = "red"
_EVENT_TYPE = "com.example.test" _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): class DelayedEventsTestCase(HomeserverTestCase):
"""Tests getting and managing delayed events.""" """Tests getting and managing delayed events."""