summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2016-02-15 14:38:27 +0000
committerDaniel Wagner-Hall <daniel@matrix.org>2016-02-15 14:38:27 +0000
commitdbeed36dec021df3036e088910c72d5727910dd3 (patch)
treef98ced054476684af05d2ce6fb4b4066fd56ecd4 /synapse
parentRevert "Merge two of the room join codepaths" (diff)
downloadsynapse-dbeed36dec021df3036e088910c72d5727910dd3.tar.xz
Merge some room joining codepaths
Force joining by alias to go through the send_membership_event checks,
rather than bypassing them straight into _do_join. This is the first of
many stages of cleanup.
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/room.py14
-rw-r--r--synapse/rest/client/v1/room.py2
2 files changed, 11 insertions, 5 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index b2de2cd0c0..89695cc0cf 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -455,7 +455,7 @@ class RoomMemberHandler(BaseHandler):
             yield self.forget(requester.user, room_id)
 
     @defer.inlineCallbacks
-    def send_membership_event(self, event, context, is_guest=False):
+    def send_membership_event(self, event, context, is_guest=False, room_hosts=None):
         """ Change the membership status of a user in a room.
 
         Args:
@@ -490,7 +490,7 @@ class RoomMemberHandler(BaseHandler):
                 if not is_guest_access_allowed:
                     raise AuthError(403, "Guest access not allowed")
 
-            yield self._do_join(event, context)
+            yield self._do_join(event, context, room_hosts=room_hosts)
         else:
             if event.membership == Membership.LEAVE:
                 is_host_in_room = yield self.is_host_in_room(room_id, context)
@@ -527,7 +527,8 @@ class RoomMemberHandler(BaseHandler):
         defer.returnValue({"room_id": room_id})
 
     @defer.inlineCallbacks
-    def join_room_alias(self, joinee, room_alias, content={}):
+    def join_room_alias(self, requester, room_alias, content={}):
+        joinee = requester.user
         directory_handler = self.hs.get_handlers().directory_handler
         mapping = yield directory_handler.get_association(room_alias)
 
@@ -553,7 +554,12 @@ class RoomMemberHandler(BaseHandler):
         })
         event, context = yield self._create_new_client_event(builder)
 
-        yield self._do_join(event, context, room_hosts=hosts)
+        yield self.send_membership_event(
+            event,
+            context,
+            is_guest=requester.is_guest,
+            room_hosts=hosts
+        )
 
         defer.returnValue({"room_id": room_id})
 
diff --git a/synapse/rest/client/v1/room.py b/synapse/rest/client/v1/room.py
index 81bfe377bd..76025213dc 100644
--- a/synapse/rest/client/v1/room.py
+++ b/synapse/rest/client/v1/room.py
@@ -246,7 +246,7 @@ class JoinRoomAliasServlet(ClientV1RestServlet):
         if is_room_alias:
             handler = self.handlers.room_member_handler
             ret_dict = yield handler.join_room_alias(
-                requester.user,
+                requester,
                 identifier,
             )
             defer.returnValue((200, ret_dict))