Merge pull request #4530 from matrix-org/anoa/room_upgrade_federatable
Copy over non-federatable trait on room upgrade
This commit is contained in:
commit
c45fd0dda0
|
@ -0,0 +1 @@
|
||||||
|
Copy over room federation ability on room upgrade.
|
|
@ -263,6 +263,16 @@ class RoomCreationHandler(BaseHandler):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if old room was non-federatable
|
||||||
|
|
||||||
|
# Get old room's create event
|
||||||
|
old_room_create_event = yield self.store.get_create_event_for_room(old_room_id)
|
||||||
|
|
||||||
|
# Check if the create event specified a non-federatable room
|
||||||
|
if not old_room_create_event.content.get("m.federate", True):
|
||||||
|
# If so, mark the new room as non-federatable as well
|
||||||
|
creation_content["m.federate"] = False
|
||||||
|
|
||||||
initial_state = dict()
|
initial_state = dict()
|
||||||
|
|
||||||
# Replicate relevant room events
|
# Replicate relevant room events
|
||||||
|
|
|
@ -428,13 +428,9 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
|
||||||
"""
|
"""
|
||||||
# for now we do this by looking at the create event. We may want to cache this
|
# for now we do this by looking at the create event. We may want to cache this
|
||||||
# more intelligently in future.
|
# more intelligently in future.
|
||||||
state_ids = yield self.get_current_state_ids(room_id)
|
|
||||||
create_id = state_ids.get((EventTypes.Create, ""))
|
|
||||||
|
|
||||||
if not create_id:
|
# Retrieve the room's create event
|
||||||
raise NotFoundError("Unknown room %s" % (room_id))
|
create_event = yield self.get_create_event_for_room(room_id)
|
||||||
|
|
||||||
create_event = yield self.get_event(create_id)
|
|
||||||
defer.returnValue(create_event.content.get("room_version", "1"))
|
defer.returnValue(create_event.content.get("room_version", "1"))
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -447,19 +443,39 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Deferred[unicode|None]: predecessor room id
|
Deferred[unicode|None]: predecessor room id
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
NotFoundError if the room is unknown
|
||||||
|
"""
|
||||||
|
# Retrieve the room's create event
|
||||||
|
create_event = yield self.get_create_event_for_room(room_id)
|
||||||
|
|
||||||
|
# Return predecessor if present
|
||||||
|
defer.returnValue(create_event.content.get("predecessor", None))
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def get_create_event_for_room(self, room_id):
|
||||||
|
"""Get the create state event for a room.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
room_id (str)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Deferred[EventBase]: The room creation event.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
NotFoundError if the room is unknown
|
||||||
"""
|
"""
|
||||||
state_ids = yield self.get_current_state_ids(room_id)
|
state_ids = yield self.get_current_state_ids(room_id)
|
||||||
create_id = state_ids.get((EventTypes.Create, ""))
|
create_id = state_ids.get((EventTypes.Create, ""))
|
||||||
|
|
||||||
# If we can't find the create event, assume we've hit a dead end
|
# If we can't find the create event, assume we've hit a dead end
|
||||||
if not create_id:
|
if not create_id:
|
||||||
defer.returnValue(None)
|
raise NotFoundError("Unknown room %s" % (room_id))
|
||||||
|
|
||||||
# Retrieve the room's create event
|
# Retrieve the room's create event and return
|
||||||
create_event = yield self.get_event(create_id)
|
create_event = yield self.get_event(create_id)
|
||||||
|
defer.returnValue(create_event)
|
||||||
# Return predecessor if present
|
|
||||||
defer.returnValue(create_event.content.get("predecessor", None))
|
|
||||||
|
|
||||||
@cached(max_entries=100000, iterable=True)
|
@cached(max_entries=100000, iterable=True)
|
||||||
def get_current_state_ids(self, room_id):
|
def get_current_state_ids(self, room_id):
|
||||||
|
|
Loading…
Reference in New Issue