diff options
author | Erik Johnston <erik@matrix.org> | 2019-01-25 14:11:17 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-01-25 14:11:17 +0000 |
commit | 431e485914b01eb1b245e37df814ff5bac110be1 (patch) | |
tree | 1262900b08616aa08768d9883349b11725218528 /synapse/storage/state.py | |
parent | Newsfile (diff) | |
parent | Fix quoting for allowed_local_3pids example config (#4476) (diff) | |
download | synapse-431e485914b01eb1b245e37df814ff5bac110be1.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/sqlite_native_upsert
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r-- | synapse/storage/state.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py index a134e9b3e8..c3ab7db7ae 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -437,6 +437,30 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore): create_event = yield self.get_event(create_id) defer.returnValue(create_event.content.get("room_version", "1")) + @defer.inlineCallbacks + def get_room_predecessor(self, room_id): + """Get the predecessor room of an upgraded room if one exists. + Otherwise return None. + + Args: + room_id (str) + + Returns: + Deferred[unicode|None]: predecessor room id + """ + state_ids = yield self.get_current_state_ids(room_id) + create_id = state_ids.get((EventTypes.Create, "")) + + # If we can't find the create event, assume we've hit a dead end + if not create_id: + defer.returnValue(None) + + # Retrieve the room's create event + create_event = yield self.get_event(create_id) + + # Return predecessor if present + defer.returnValue(create_event.content.get("predecessor", None)) + @cached(max_entries=100000, iterable=True) def get_current_state_ids(self, room_id): """Get the current state event ids for a room based on the |