summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-11-02 15:11:31 +0000
committerMark Haines <mark.haines@matrix.org>2015-11-02 15:11:31 +0000
commitddd8566f415ab3a6092aa4947e5d2aebf67109fc (patch)
treeeab8cc4d46e1ab7446b990d8eb5556e65304c0a1 /synapse/rest
parentMerge branch 'develop' into markjh/room_tags (diff)
downloadsynapse-ddd8566f415ab3a6092aa4947e5d2aebf67109fc.tar.xz
Store room tag content and return the content in the m.tag event
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/client/v2_alpha/tags.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/synapse/rest/client/v2_alpha/tags.py b/synapse/rest/client/v2_alpha/tags.py
index 486add9909..4e3f917fc5 100644
--- a/synapse/rest/client/v2_alpha/tags.py
+++ b/synapse/rest/client/v2_alpha/tags.py
@@ -16,12 +16,14 @@
 from ._base import client_v2_pattern
 
 from synapse.http.servlet import RestServlet
-from synapse.api.errors import AuthError
+from synapse.api.errors import AuthError, SynapseError
 
 from twisted.internet import defer
 
 import logging
 
+import simplejson as json
+
 logger = logging.getLogger(__name__)
 
 
@@ -70,7 +72,13 @@ class TagServlet(RestServlet):
         if user_id != auth_user.to_string():
             raise AuthError(403, "Cannot add tags for other users.")
 
-        max_id = yield self.store.add_tag_to_room(user_id, room_id, tag)
+        try:
+            content_bytes = request.content.read()
+            body = json.loads(content_bytes)
+        except:
+            raise SynapseError(400, "Invalid tag JSON")
+
+        max_id = yield self.store.add_tag_to_room(user_id, room_id, tag, body)
 
         yield self.notifier.on_new_event(
             "private_user_data_key", max_id, users=[user_id]