diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2019-02-18 14:52:23 +0000 |
---|---|---|
committer | Brendan Abolivier <babolivier@matrix.org> | 2019-02-18 14:52:23 +0000 |
commit | 68a53f825fc3ecb415571bda2bfc7c1df5edefb7 (patch) | |
tree | 8f71f2a3123fe30230d798259eca391794c52d48 /synapse/storage | |
parent | Typo in changelog (diff) | |
parent | Merge pull request #4643 from matrix-org/erikj/catch_exceptions (diff) | |
download | synapse-68a53f825fc3ecb415571bda2bfc7c1df5edefb7.tar.xz |
Merge branch 'develop' into babolivier/acme-delegated
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/state.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py index d14a7b2538..6ddc4055d2 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -548,6 +548,31 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore): _get_filtered_current_state_ids_txn, ) + @defer.inlineCallbacks + def get_canonical_alias_for_room(self, room_id): + """Get canonical alias for room, if any + + Args: + room_id (str) + + Returns: + Deferred[str|None]: The canonical alias, if any + """ + + state = yield self.get_filtered_current_state_ids(room_id, StateFilter.from_types( + [(EventTypes.CanonicalAlias, "")] + )) + + event_id = state.get((EventTypes.CanonicalAlias, "")) + if not event_id: + return + + event = yield self.get_event(event_id, allow_none=True) + if not event: + return + + defer.returnValue(event.content.get("canonical_alias")) + @cached(max_entries=10000, iterable=True) def get_state_group_delta(self, state_group): """Given a state group try to return a previous group and a delta between |