summary refs log tree commit diff
path: root/synapse/module_api
diff options
context:
space:
mode:
authorMatt C <96466754+buffless-matt@users.noreply.github.com>2022-08-03 19:25:36 +1000
committerGitHub <noreply@github.com>2022-08-03 09:25:36 +0000
commit570bf32bbb9b4bd31a9783746187769613591499 (patch)
treeaab250e9667a795f3a207ac35f1c3c26fbaa3e07 /synapse/module_api
parentRemove 'Contents' section from the Configuration Manual (#13438) (diff)
downloadsynapse-570bf32bbb9b4bd31a9783746187769613591499.tar.xz
Add module API method to resolve a room alias to a room ID (#13428)
Co-authored-by: MattC <buffless-matt@users.noreply.github.com>
Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
Diffstat (limited to 'synapse/module_api')
-rw-r--r--synapse/module_api/__init__.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py
index 6d8bf54083..18d6d1058a 100644
--- a/synapse/module_api/__init__.py
+++ b/synapse/module_api/__init__.py
@@ -1452,6 +1452,30 @@ class ModuleApi:
             start_timestamp, end_timestamp
         )
 
+    async def lookup_room_alias(self, room_alias: str) -> Tuple[str, List[str]]:
+        """
+        Get the room ID associated with a room alias.
+
+        Added in Synapse v1.65.0.
+
+        Args:
+            room_alias: The alias to look up.
+
+        Returns:
+            A tuple of:
+                The room ID (str).
+                Hosts likely to be participating in the room ([str]).
+
+        Raises:
+            SynapseError if room alias is invalid or could not be found.
+        """
+        alias = RoomAlias.from_string(room_alias)
+        (room_id, hosts) = await self._hs.get_room_member_handler().lookup_room_alias(
+            alias
+        )
+
+        return room_id.to_string(), hosts
+
 
 class PublicRoomListManager:
     """Contains methods for adding to, removing from and querying whether a room