summary refs log tree commit diff
path: root/synapse/rest/room.py
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-27 11:33:56 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-27 11:33:56 +0100
commitdd661769e1846b627d26203f6ca7936e0820d93c (patch)
tree874a737fba65d5c8e515e9fa93ff7707dcff9a97 /synapse/rest/room.py
parentAdded support for GET /events/$eventid with auth checks. (diff)
downloadsynapse-dd661769e1846b627d26203f6ca7936e0820d93c.tar.xz
Renamed /rooms to /createRoom. Removed ability to PUT raw room IDs, and removed tests which tested that. Updated cmdclient and webclient.
Diffstat (limited to 'synapse/rest/room.py')
-rw-r--r--synapse/rest/room.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/synapse/rest/room.py b/synapse/rest/room.py
index b8d5cb87fd..1cbb31e301 100644
--- a/synapse/rest/room.py
+++ b/synapse/rest/room.py
@@ -34,31 +34,28 @@ class RoomCreateRestServlet(RestServlet):
     # No PATTERN; we have custom dispatch rules here
 
     def register(self, http_server):
-        # /rooms OR /rooms/<roomid>
-        http_server.register_path("POST",
-                                  client_path_pattern("/rooms$"),
-                                  self.on_POST)
-        http_server.register_path("PUT",
-                                  client_path_pattern(
-                                      "/rooms/(?P<room_id>[^/]*)$"),
-                                  self.on_PUT)
+        PATTERN = "/createRoom"
+        register_txn_path(self, PATTERN, http_server)
         # define CORS for all of /rooms in RoomCreateRestServlet for simplicity
         http_server.register_path("OPTIONS",
                                   client_path_pattern("/rooms(?:/.*)?$"),
                                   self.on_OPTIONS)
+        # define CORS for /createRoom[/txnid]
+        http_server.register_path("OPTIONS",
+                                  client_path_pattern("/createRoom(?:/.*)?$"),
+                                  self.on_OPTIONS)
 
     @defer.inlineCallbacks
-    def on_PUT(self, request, room_id):
-        room_id = urllib.unquote(room_id)
-        auth_user = yield self.auth.get_user_by_req(request)
+    def on_PUT(self, request, txn_id):
+        try:
+            defer.returnValue(self.txns.get_client_transaction(request, txn_id))
+        except KeyError:
+            pass
 
-        if not room_id:
-            raise SynapseError(400, "PUT must specify a room ID")
+        response = yield self.on_POST(request)
 
-        room_config = self.get_room_config(request)
-        info = yield self.make_room(room_config, auth_user, room_id)
-        room_config.update(info)
-        defer.returnValue((200, info))
+        self.txns.store_client_transaction(request, txn_id, response)
+        defer.returnValue(response)
 
     @defer.inlineCallbacks
     def on_POST(self, request):