mirror of
https://github.com/element-hq/synapse.git
synced 2026-10-23 04:23:10 +00:00
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:
1 parent
57d6da409c
commit
a92a21600c
4 files changed
+7
-4
No files matched your search
@@ -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.
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user