summary refs log tree commit diff
path: root/synapse/storage/state.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-02-14 16:02:23 +0000
committerErik Johnston <erik@matrix.org>2019-02-14 16:02:23 +0000
commiteaf4d11af9da7d6d9ce71cb83f70424bb38e0703 (patch)
tree06a48ce6758859dd3a4bee76047b5b6bd53af402 /synapse/storage/state.py
parentMerge pull request #4450 from 14mRh4X0r/fix-dependency-message (diff)
downloadsynapse-eaf4d11af9da7d6d9ce71cb83f70424bb38e0703.tar.xz
Add configurable room list publishing rules
This allows specifying who and what is allowed to be published onto the
public room list
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r--synapse/storage/state.py25
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