Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Make room creations denied by user_may_create_room cause an `M_FORB…
Browse files Browse the repository at this point in the history
…IDDEN` error to be returned, not `M_UNKNOWN` (#11672)

Co-authored-by: reivilibre <[email protected]>
  • Loading branch information
lukasdenk and reivilibre authored Jan 6, 2022
1 parent c9eb678 commit 2ef1fea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/11672.feature
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 6 additions & 2 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ async def clone_existing_room(
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,
Expand Down Expand Up @@ -685,7 +687,9 @@ async def create_room(
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)
Expand Down

0 comments on commit 2ef1fea

Please sign in to comment.