Membership events are done later

This commit is contained in:
Andrew Morgan 2019-02-18 14:02:09 +00:00
parent 7033b05cad
commit 915421065b

View file

@ -294,21 +294,14 @@ class RoomCreationHandler(BaseHandler):
# map from event_id to BaseEvent # map from event_id to BaseEvent
old_room_state_events = yield self.store.get_events(old_room_state_ids.values()) old_room_state_events = yield self.store.get_events(old_room_state_ids.values())
member_events = []
for k, old_event_id in iteritems(old_room_state_ids): for k, old_event_id in iteritems(old_room_state_ids):
old_event = old_room_state_events.get(old_event_id) old_event = old_room_state_events.get(old_event_id)
if old_event: if old_event:
# Do membership events later
# Only transfer ban membership events if ("membership" in old_event.content):
if ("membership" in old_event.content and member_events.append(old_event)
old_event.content["membership"] == "ban"): continue
yield self.room_member_handler.update_membership(
requester,
UserID.from_string(old_event['state_key']),
room_id,
"ban",
ratelimit=False,
content=old_event.content,
)
initial_state[k] = old_event.content initial_state[k] = old_event.content
@ -325,6 +318,21 @@ class RoomCreationHandler(BaseHandler):
creation_content=creation_content, creation_content=creation_content,
) )
# Transfer membership events
for old_event in member_events:
# Only transfer ban events
logger.info("Event type: " + str(old_event.content))
if ("membership" in old_event.content and
old_event.content["membership"] == "ban"):
yield self.room_member_handler.update_membership(
requester,
UserID.from_string(old_event['state_key']),
new_room_id,
"ban",
ratelimit=False,
content=old_event.content,
)
# XXX invites/joins # XXX invites/joins
# XXX 3pid invites # XXX 3pid invites