Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add module API method to resolve a room alias to a room ID #13428

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/13428.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add module API method to translate a room alias to a room ID.
babolivier marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 22 additions & 0 deletions synapse/module_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,28 @@ async def get_monthly_active_users_by_service(
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.
babolivier marked this conversation as resolved.
Show resolved Hide resolved
"""
alias = RoomAlias.from_string(room_alias)
(room_id, hosts) = await self._hs.get_room_member_handler().lookup_room_alias(
babolivier marked this conversation as resolved.
Show resolved Hide resolved
alias
)

return room_id.to_string(), hosts


class PublicRoomListManager:
"""Contains methods for adding to, removing from and querying whether a room
Expand Down