mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-09-08 05:01:58 +00:00
SYN-154: Tweak how the m.room.create check is done.
Don't perform the check in auth.is_host_in_room but instead do it in _do_join and also assert that there are no m.room.members in the room before doing so.
This commit is contained in:
parent
9cb4f75d53
commit
4c68460392
@ -98,16 +98,7 @@ class Auth(object):
|
|||||||
defer.returnValue(member)
|
defer.returnValue(member)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def check_host_in_room(self, room_id, host, context=None):
|
def check_host_in_room(self, room_id, host):
|
||||||
if context:
|
|
||||||
# XXX: check_host_in_room should really return True for a new
|
|
||||||
# room created by this home server. There are no m.room.member
|
|
||||||
# join events yet so we need to check for the m.room.create event
|
|
||||||
# instead.
|
|
||||||
if (u"m.room.create", u"") in context.auth_events:
|
|
||||||
defer.returnValue(True)
|
|
||||||
return
|
|
||||||
|
|
||||||
curr_state = yield self.state.get_current_state(room_id)
|
curr_state = yield self.state.get_current_state(room_id)
|
||||||
|
|
||||||
for event in curr_state:
|
for event in curr_state:
|
||||||
|
@ -423,9 +423,18 @@ class RoomMemberHandler(BaseHandler):
|
|||||||
|
|
||||||
is_host_in_room = yield self.auth.check_host_in_room(
|
is_host_in_room = yield self.auth.check_host_in_room(
|
||||||
event.room_id,
|
event.room_id,
|
||||||
self.hs.hostname,
|
self.hs.hostname
|
||||||
context=context
|
|
||||||
)
|
)
|
||||||
|
if not is_host_in_room:
|
||||||
|
# is *anyone* in the room?
|
||||||
|
room_member_keys = [
|
||||||
|
v for (k,v) in context.current_state.keys() if k == "m.room.member"
|
||||||
|
]
|
||||||
|
if len(room_member_keys) == 0:
|
||||||
|
# has the room been created so we can join it?
|
||||||
|
create_event = context.current_state.get(("m.room.create", ""))
|
||||||
|
if create_event:
|
||||||
|
is_host_in_room = True
|
||||||
|
|
||||||
if is_host_in_room:
|
if is_host_in_room:
|
||||||
should_do_dance = False
|
should_do_dance = False
|
||||||
|
Loading…
Reference in New Issue
Block a user