mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 00:54:47 -04:00
Allow guest users to join and message rooms
This commit is contained in:
parent
82e8a2d763
commit
38d82edf0e
7 changed files with 92 additions and 12 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue