summary refs log tree commit diff
path: root/synapse/rest/client/v1/presence.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2016-03-11 16:41:03 +0000
committerMark Haines <mark.haines@matrix.org>2016-03-11 16:41:03 +0000
commite9c1cabac26cf8e28152ebdb3caf29d4457eea0e (patch)
tree792ef6135a1a1a52f39a83a8e2ff6e2e28e949c7 /synapse/rest/client/v1/presence.py
parentFix SQL statement (diff)
downloadsynapse-e9c1cabac26cf8e28152ebdb3caf29d4457eea0e.tar.xz
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.py13
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"]: