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

Commit

Permalink
Merge pull request #4642 from matrix-org/anoa/bans_room_upgrade
Browse files Browse the repository at this point in the history
Transfer bans on room upgrade
  • Loading branch information
anoadragon453 authored Feb 19, 2019
2 parents d154f5a + 34ac75c commit 968a30a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/4642.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Transfer bans on room upgrade.
22 changes: 22 additions & 0 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,28 @@ def clone_existing_room(
creation_content=creation_content,
)

# Transfer membership events
old_room_member_state_ids = yield self.store.get_filtered_current_state_ids(
old_room_id, StateFilter.from_types([(EventTypes.Member, None)]),
)

# map from event_id to BaseEvent
old_room_member_state_events = yield self.store.get_events(
old_room_member_state_ids.values(),
)
for k, old_event in iteritems(old_room_member_state_events):
# Only transfer ban 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']),
new_room_id,
"ban",
ratelimit=False,
content=old_event.content,
)

# XXX invites/joins
# XXX 3pid invites

Expand Down

0 comments on commit 968a30a

Please sign in to comment.