diff options
author | lukasdenk <63459921+lukasdenk@users.noreply.github.com> | 2022-01-06 14:16:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-06 13:16:42 +0000 |
commit | 2ef1fea8d2021e7a42259d21b57b32e9a7f04f1a (patch) | |
tree | 0b1d28325349cc2ba488d6c7badb31b6d4820c2c | |
parent | Remove debug logging for #4422 (#11693) (diff) | |
download | synapse-2ef1fea8d2021e7a42259d21b57b32e9a7f04f1a.tar.xz |
Make room creations denied by `user_may_create_room` cause an `M_FORBIDDEN` error to be returned, not `M_UNKNOWN` (#11672)
Co-authored-by: reivilibre <olivier@librepush.net>
-rw-r--r-- | changelog.d/11672.feature | 1 | ||||
-rw-r--r-- | synapse/handlers/room.py | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/changelog.d/11672.feature b/changelog.d/11672.feature new file mode 100644 index 0000000000..ce8b3e9547 --- /dev/null +++ b/changelog.d/11672.feature @@ -0,0 +1 @@ +Return an `M_FORBIDDEN` error code instead of `M_UNKNOWN` when a spam checker module prevents a user from creating a room. diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index b9c1cbffa5..3d3a0f6ac3 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -393,7 +393,9 @@ class RoomCreationHandler: user_id = requester.user.to_string() if not await self.spam_checker.user_may_create_room(user_id): - raise SynapseError(403, "You are not permitted to create rooms") + raise SynapseError( + 403, "You are not permitted to create rooms", Codes.FORBIDDEN + ) creation_content: JsonDict = { "room_version": new_room_version.identifier, @@ -685,7 +687,9 @@ class RoomCreationHandler: invite_3pid_list, ) ): - raise SynapseError(403, "You are not permitted to create rooms") + raise SynapseError( + 403, "You are not permitted to create rooms", Codes.FORBIDDEN + ) if ratelimit: await self.request_ratelimiter.ratelimit(requester) |