MSC4140: update error for exceeding delay maximum (#20156)

Use the HTTP code & errcode specified in the latest revision of the MSC

(The changes were added by
https://github.com/matrix-org/matrix-spec-proposals/pull/4140/changes/0c7193aaa07c9a2634dccd7cf3bd83e2733a806e)
This commit is contained in:
Andrew Ferrazzutti authored and GitHub committed 2026-08-28 08:53:30 -04:00
1 parent 57d6da409c
commit a92a21600c
4 files changed
+7 -4

No files matched your search

+1
View File
@@ -0,0 +1 @@
[MSC4140: Cancellable delayed events](https://github.com/matrix-org/matrix-spec-proposals/pull/4140): Update the error response for requesting to schedule a delayed event with a delay that exceeds the server-enforced maximum delay.
+2
View File
@@ -137,6 +137,8 @@ class Codes(str, Enum):
PROFILE_TOO_LARGE = "M_PROFILE_TOO_LARGE"
KEY_TOO_LARGE = "M_KEY_TOO_LARGE"
DELAY_TOO_LARGE = "ORG.MATRIX.MSC4140_DELAY_TOO_LARGE"
# Part of MSC4155/MSC4380
INVITE_BLOCKED = "M_INVITE_BLOCKED"
+2 -2
View File
@@ -373,9 +373,9 @@ class DelayedEventsHandler:
requested_delay = delay.as_millis()
max_delay = self._config.server.max_event_delay_duration.as_millis()
raise SynapseError(
HTTPStatus.FORBIDDEN,
HTTPStatus.BAD_REQUEST,
f"The requested delay ({requested_delay}ms) exceeds the allowed maximum ({max_delay}ms)",
Codes.FORBIDDEN,
Codes.DELAY_TOO_LARGE,
)
self._event_creation_handler.validator.validate_builder(
+2 -2
View File
@@ -2567,9 +2567,9 @@ class RoomDelayedEventTestCase(RoomBase):
).encode("ascii"),
{"body": "test", "msgtype": "m.text"},
)
self.assertEqual(HTTPStatus.FORBIDDEN, channel.code, channel.result)
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, channel.result)
self.assertEqual(
Codes.FORBIDDEN,
"ORG.MATRIX.MSC4140_DELAY_TOO_LARGE",
channel.json_body.get("errcode"),
channel.json_body,
)