diff options
author | Hubert Chathi <hubert@uhoreg.ca> | 2018-08-24 11:44:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-24 11:44:26 -0400 |
commit | 83caead95a921b0977164468a52c5c0b6e9eee5a (patch) | |
tree | e87ae6c5d439de1e1dfd7598cab35a14e320ef59 /synapse/handlers/room.py | |
parent | allow session_data to be any JSON instead of just a string (diff) | |
parent | Merge pull request #3755 from matrix-org/erikj/fix_server_notice_tags (diff) | |
download | synapse-83caead95a921b0977164468a52c5c0b6e9eee5a.tar.xz |
Merge branch 'develop' into e2e_backups
Diffstat (limited to 'synapse/handlers/room.py')
-rw-r--r-- | synapse/handlers/room.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 7b7804d9b2..c3f820b975 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -21,9 +21,17 @@ import math import string from collections import OrderedDict +from six import string_types + from twisted.internet import defer -from synapse.api.constants import EventTypes, JoinRules, RoomCreationPreset +from synapse.api.constants import ( + DEFAULT_ROOM_VERSION, + KNOWN_ROOM_VERSIONS, + EventTypes, + JoinRules, + RoomCreationPreset, +) from synapse.api.errors import AuthError, Codes, StoreError, SynapseError from synapse.types import RoomAlias, RoomID, RoomStreamToken, StreamToken, UserID from synapse.util import stringutils @@ -90,15 +98,34 @@ class RoomCreationHandler(BaseHandler): Raises: SynapseError if the room ID couldn't be stored, or something went horribly wrong. + ResourceLimitError if server is blocked to some resource being + exceeded """ user_id = requester.user.to_string() + self.auth.check_auth_blocking(user_id) + if not self.spam_checker.user_may_create_room(user_id): raise SynapseError(403, "You are not permitted to create rooms") if ratelimit: yield self.ratelimit(requester) + room_version = config.get("room_version", DEFAULT_ROOM_VERSION) + if not isinstance(room_version, string_types): + raise SynapseError( + 400, + "room_version must be a string", + Codes.BAD_JSON, + ) + + if room_version not in KNOWN_ROOM_VERSIONS: + raise SynapseError( + 400, + "Your homeserver does not support this room version", + Codes.UNSUPPORTED_ROOM_VERSION, + ) + if "room_alias_name" in config: for wchar in string.whitespace: if wchar in config["room_alias_name"]: @@ -184,6 +211,9 @@ class RoomCreationHandler(BaseHandler): creation_content = config.get("creation_content", {}) + # override any attempt to set room versions via the creation_content + creation_content["room_version"] = room_version + room_member_handler = self.hs.get_room_member_handler() yield self._send_events_for_new_room( |