summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-08-13 17:43:10 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-08-13 18:03:41 +0100
commit7fb93f2a47ab8abc44a9b6a94171950a40f6ba33 (patch)
treeb82af6bb6e2432a38e989ba2bdf44c213f75d2cb /synapse/rest
parentUpdate graph.py to use new federation urls (diff)
downloadsynapse-7fb93f2a47ab8abc44a9b6a94171950a40f6ba33.tar.xz
Add a HomeServer.parse_roomalias() to avoid having to RoomAlias.from_sring(..., hs=hs) - similar to parse_userid()
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/directory.py13
-rw-r--r--synapse/rest/room.py6
2 files changed, 6 insertions, 13 deletions
diff --git a/synapse/rest/directory.py b/synapse/rest/directory.py
index 31fd26e848..362f76c6ca 100644
--- a/synapse/rest/directory.py
+++ b/synapse/rest/directory.py
@@ -16,7 +16,6 @@
 
 from twisted.internet import defer
 
-from synapse.types import RoomAlias, RoomID
 from base import RestServlet, client_path_pattern
 
 import json
@@ -39,12 +38,11 @@ class ClientDirectoryServer(RestServlet):
         # TODO(erikj): Handle request
         local_only = "local_only" in request.args
 
-        room_alias = urllib.unquote(room_alias)
-        room_alias_obj = RoomAlias.from_string(room_alias, self.hs)
+        room_alias = self.hs.parse_roomalias(urllib.unquote(room_alias))
 
         dir_handler = self.handlers.directory_handler
         res = yield dir_handler.get_association(
-            room_alias_obj,
+            room_alias,
             local_only=local_only
         )
 
@@ -57,10 +55,9 @@ class ClientDirectoryServer(RestServlet):
 
         logger.debug("Got content: %s", content)
 
-        room_alias = urllib.unquote(room_alias)
-        room_alias_obj = RoomAlias.from_string(room_alias, self.hs)
+        room_alias = self.hs.parse_roomalias(urllib.unquote(room_alias))
 
-        logger.debug("Got room name: %s", room_alias_obj.to_string())
+        logger.debug("Got room name: %s", room_alias.to_string())
 
         room_id = content["room_id"]
         servers = content["servers"]
@@ -75,7 +72,7 @@ class ClientDirectoryServer(RestServlet):
 
         try:
             yield dir_handler.create_association(
-                room_alias_obj, room_id, servers
+                room_alias, room_id, servers
             )
         except:
             logger.exception("Failed to create association")
diff --git a/synapse/rest/room.py b/synapse/rest/room.py
index 228bc9623d..1fc0c996b8 100644
--- a/synapse/rest/room.py
+++ b/synapse/rest/room.py
@@ -22,7 +22,6 @@ from synapse.api.events.room import (RoomTopicEvent, MessageEvent,
                                      RoomMemberEvent, FeedbackEvent)
 from synapse.api.constants import Feedback, Membership
 from synapse.api.streams import PaginationConfig
-from synapse.types import RoomAlias
 
 import json
 import logging
@@ -150,10 +149,7 @@ class JoinRoomAliasServlet(RestServlet):
 
         logger.debug("room_alias: %s", room_alias)
 
-        room_alias = RoomAlias.from_string(
-            urllib.unquote(room_alias),
-            self.hs
-        )
+        room_alias = self.hs.parse_roomalias(urllib.unquote(room_alias))
 
         handler = self.handlers.room_member_handler
         ret_dict = yield handler.join_room_alias(user, room_alias)