summary refs log tree commit diff
path: root/synapse/handlers/room.py
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2015-11-10 16:57:13 +0000
committerDaniel Wagner-Hall <daniel@matrix.org>2015-11-10 16:57:13 +0000
commit38d82edf0e463e1e6eb6859330f2517cc7ae3e41 (patch)
treedcf5f90f670641aec7adb957186fd23f8d5b916f /synapse/handlers/room.py
parentMerge pull request #356 from matrix-org/daniel/3pidyetagain (diff)
downloadsynapse-38d82edf0e463e1e6eb6859330f2517cc7ae3e41.tar.xz
Allow guest users to join and message rooms
Diffstat (limited to 'synapse/handlers/room.py')
-rw-r--r--synapse/handlers/room.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 834972a580..7d18218cd9 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -369,7 +369,7 @@ class RoomMemberHandler(BaseHandler):
                     remotedomains.add(member.domain)
 
     @defer.inlineCallbacks
-    def change_membership(self, event, context, do_auth=True):
+    def change_membership(self, event, context, do_auth=True, is_guest=False):
         """ Change the membership status of a user in a room.
 
         Args:
@@ -390,6 +390,20 @@ class RoomMemberHandler(BaseHandler):
         # if this HS is not currently in the room, i.e. we have to do the
         # invite/join dance.
         if event.membership == Membership.JOIN:
+            if is_guest:
+                guest_access = context.current_state.get(
+                    (EventTypes.GuestAccess, ""),
+                    None
+                )
+                is_guest_access_allowed = (
+                    guest_access
+                    and guest_access.content
+                    and "guest_access" in guest_access.content
+                    and guest_access.content["guest_access"] == "can_join"
+                )
+                if not is_guest_access_allowed:
+                    raise AuthError(403, "Guest access not allowed")
+
             yield self._do_join(event, context, do_auth=do_auth)
         else:
             if event.membership == Membership.LEAVE: