diff options
author | Mark Haines <mjark@negativecurvature.net> | 2016-03-11 17:27:37 +0000 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2016-03-11 17:27:37 +0000 |
commit | ffb9dd02feaeef7766c603952bc382ca1e75dcca (patch) | |
tree | 792ef6135a1a1a52f39a83a8e2ff6e2e28e949c7 /synapse/rest/client/v1/room.py | |
parent | Fix SQL statement (diff) | |
parent | Use parse_json_object_from_request to parse JSON out of request bodies (diff) | |
download | synapse-ffb9dd02feaeef7766c603952bc382ca1e75dcca.tar.xz |
Merge pull request #643 from matrix-org/markjh/parse_json_II
Use parse_json_object_from_request to parse JSON out of request bodies
Diffstat (limited to 'synapse/rest/client/v1/room.py')
-rw-r--r-- | synapse/rest/client/v1/room.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/synapse/rest/client/v1/room.py b/synapse/rest/client/v1/room.py index 7a9f3d11b9..a1fa7daf79 100644 --- a/synapse/rest/client/v1/room.py +++ b/synapse/rest/client/v1/room.py @@ -24,7 +24,6 @@ from synapse.types import UserID, RoomID, RoomAlias from synapse.events.utils import serialize_event from synapse.http.servlet import parse_json_object_from_request -import simplejson as json import logging import urllib @@ -72,15 +71,10 @@ class RoomCreateRestServlet(ClientV1RestServlet): defer.returnValue((200, info)) def get_room_config(self, request): - try: - user_supplied_config = json.loads(request.content.read()) - if "visibility" not in user_supplied_config: - # default visibility - user_supplied_config["visibility"] = "public" - return user_supplied_config - except (ValueError, TypeError): - raise SynapseError(400, "Body must be JSON.", - errcode=Codes.BAD_JSON) + user_supplied_config = parse_json_object_from_request(request) + # default visibility + user_supplied_config.setdefault("visibility", "public") + return user_supplied_config def on_OPTIONS(self, request): return (200, {}) |