summary refs log tree commit diff
path: root/synapse/storage/directory.py
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-02-25 17:15:25 +0000
committerKegan Dougal <kegan@matrix.org>2015-02-25 17:15:25 +0000
commit2b8ca84296b228b7cef09244605e4f2760349538 (patch)
tree770c0503383e8f1dbe539252e4d91034f01a6e81 /synapse/storage/directory.py
parentAdd stub functions and work out execution flow to implement AS event stream p... (diff)
downloadsynapse-2b8ca84296b228b7cef09244605e4f2760349538.tar.xz
Add support for extracting matching room_ids and room_aliases for a given AS.
Diffstat (limited to 'synapse/storage/directory.py')
-rw-r--r--synapse/storage/directory.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/synapse/storage/directory.py b/synapse/storage/directory.py
index 68b7d59693..e13b336934 100644
--- a/synapse/storage/directory.py
+++ b/synapse/storage/directory.py
@@ -134,6 +134,29 @@ class DirectoryStore(SQLBaseStore):
 
         return room_id
 
+    @defer.inlineCallbacks
+    def get_all_associations(self):
+        """Retrieve the entire list of room alias -> room ID pairings.
+
+        Returns:
+            A list of RoomAliasMappings.
+        """
+        results = self._simple_select_list(
+            "room_aliases",
+            None,
+            ["room_alias", "room_id"]
+        )
+        # TODO(kegan): It feels wrong to be specifying no servers here, but
+        # equally this function isn't required to obtain all servers so
+        # retrieving them "just for the sake of it" also seems wrong, but we
+        # want to conform to passing Objects around and not dicts..
+        return [
+            RoomAliasMapping(
+                room_id=r["room_id"], room_alias=r["room_alias"], servers=""
+            ) for r in results
+        ]
+
+
     def get_aliases_for_room(self, room_id):
         return self._simple_select_onecol(
             "room_aliases",