Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Membership events are done later
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Feb 18, 2019
1 parent 7033b05 commit 9154210
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,21 +294,14 @@ def clone_existing_room(
# map from event_id to BaseEvent
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):
old_event = old_room_state_events.get(old_event_id)
if old_event:

# Only transfer ban membership events
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']),
room_id,
"ban",
ratelimit=False,
content=old_event.content,
)
# Do membership events later
if ("membership" in old_event.content):
member_events.append(old_event)
continue

initial_state[k] = old_event.content

Expand All @@ -325,6 +318,21 @@ def clone_existing_room(
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 3pid invites

Expand Down

0 comments on commit 9154210

Please sign in to comment.