diff --git a/src/service/rooms/alias/mod.rs b/src/service/rooms/alias/mod.rs index 6397ef7f..9f66cf88 100644 --- a/src/service/rooms/alias/mod.rs +++ b/src/service/rooms/alias/mod.rs @@ -12,7 +12,7 @@ use ruma::{ room::power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent}, StateEventType, }, - OwnedRoomAliasId, OwnedRoomId, OwnedServerName, RoomAliasId, RoomId, UserId, + OwnedRoomAliasId, OwnedRoomId, OwnedServerName, RoomAliasId, RoomId, RoomOrAliasId, UserId, }; use crate::{appservice::RegistrationInfo, server_is_ours, services}; @@ -52,6 +52,16 @@ impl Service { } } + pub async fn resolve(&self, room: &RoomOrAliasId) -> Result { + if room.is_room_id() { + let room_id: &RoomId = &RoomId::parse(room).expect("valid RoomId"); + Ok(room_id.to_owned()) + } else { + let alias: &RoomAliasId = &RoomAliasId::parse(room).expect("valid RoomAliasId"); + Ok(self.resolve_alias(alias, None).await?.0) + } + } + #[tracing::instrument(skip(self), name = "resolve")] pub async fn resolve_alias( &self, room_alias: &RoomAliasId, servers: Option<&Vec>,