Implement MSC3818: copy room type on upgrade (#12786)

Resolves: #11896

Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info>
This commit is contained in:
Aminda Suomalainen 2022-05-19 14:28:10 +03:00 committed by GitHub
parent 47619017f9
commit d25935cd3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -0,0 +1 @@
Implement [MSC3818: Copy room type on upgrade](https://github.com/matrix-org/matrix-spec-proposals/pull/3818).

View File

@ -469,14 +469,14 @@ class RoomCreationHandler:
(EventTypes.PowerLevels, ""), (EventTypes.PowerLevels, ""),
] ]
# If the old room was a space, copy over the room type and the rooms in # Copy the room type as per MSC3818.
# the space. room_type = old_room_create_event.content.get(EventContentFields.ROOM_TYPE)
if ( if room_type is not None:
old_room_create_event.content.get(EventContentFields.ROOM_TYPE) creation_content[EventContentFields.ROOM_TYPE] = room_type
== RoomTypes.SPACE
): # If the old room was a space, copy over the rooms in the space.
creation_content[EventContentFields.ROOM_TYPE] = RoomTypes.SPACE if room_type == RoomTypes.SPACE:
types_to_copy.append((EventTypes.SpaceChild, None)) types_to_copy.append((EventTypes.SpaceChild, None))
old_room_state_ids = await self.store.get_filtered_current_state_ids( old_room_state_ids = await self.store.get_filtered_current_state_ids(
old_room_id, StateFilter.from_types(types_to_copy) old_room_id, StateFilter.from_types(types_to_copy)