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/presence.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/presence.py')
-rw-r--r-- | synapse/rest/client/v1/presence.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/synapse/rest/client/v1/presence.py b/synapse/rest/client/v1/presence.py index bbfa1d6ac4..27d9ed586b 100644 --- a/synapse/rest/client/v1/presence.py +++ b/synapse/rest/client/v1/presence.py @@ -19,9 +19,9 @@ from twisted.internet import defer from synapse.api.errors import SynapseError, AuthError from synapse.types import UserID +from synapse.http.servlet import parse_json_object_from_request from .base import ClientV1RestServlet, client_path_patterns -import simplejson as json import logging logger = logging.getLogger(__name__) @@ -56,9 +56,10 @@ class PresenceStatusRestServlet(ClientV1RestServlet): raise AuthError(403, "Can only set your own presence state") state = {} - try: - content = json.loads(request.content.read()) + content = parse_json_object_from_request(request) + + try: state["presence"] = content.pop("presence") if "status_msg" in content: @@ -113,11 +114,7 @@ class PresenceListRestServlet(ClientV1RestServlet): raise SynapseError( 400, "Cannot modify another user's presence list") - try: - content = json.loads(request.content.read()) - except: - logger.exception("JSON parse error") - raise SynapseError(400, "Unable to parse content") + content = parse_json_object_from_request(request) if "invite" in content: for u in content["invite"]: |