mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 13:29:21 -05:00
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.
This commit is contained in:
parent
4de08a4672
commit
dbeed36dec
@ -455,7 +455,7 @@ class RoomMemberHandler(BaseHandler):
|
|||||||
yield self.forget(requester.user, room_id)
|
yield self.forget(requester.user, room_id)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@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.
|
""" Change the membership status of a user in a room.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -490,7 +490,7 @@ class RoomMemberHandler(BaseHandler):
|
|||||||
if not is_guest_access_allowed:
|
if not is_guest_access_allowed:
|
||||||
raise AuthError(403, "Guest access not 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:
|
else:
|
||||||
if event.membership == Membership.LEAVE:
|
if event.membership == Membership.LEAVE:
|
||||||
is_host_in_room = yield self.is_host_in_room(room_id, context)
|
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.returnValue({"room_id": room_id})
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@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
|
directory_handler = self.hs.get_handlers().directory_handler
|
||||||
mapping = yield directory_handler.get_association(room_alias)
|
mapping = yield directory_handler.get_association(room_alias)
|
||||||
|
|
||||||
@ -553,7 +554,12 @@ class RoomMemberHandler(BaseHandler):
|
|||||||
})
|
})
|
||||||
event, context = yield self._create_new_client_event(builder)
|
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})
|
defer.returnValue({"room_id": room_id})
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ class JoinRoomAliasServlet(ClientV1RestServlet):
|
|||||||
if is_room_alias:
|
if is_room_alias:
|
||||||
handler = self.handlers.room_member_handler
|
handler = self.handlers.room_member_handler
|
||||||
ret_dict = yield handler.join_room_alias(
|
ret_dict = yield handler.join_room_alias(
|
||||||
requester.user,
|
requester,
|
||||||
identifier,
|
identifier,
|
||||||
)
|
)
|
||||||
defer.returnValue((200, ret_dict))
|
defer.returnValue((200, ret_dict))
|
||||||
|
Loading…
Reference in New Issue
Block a user