add convenience alias resolver to interface
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
fa02d7b7e3
commit
f127987c7a
1 changed files with 11 additions and 1 deletions
|
@ -12,7 +12,7 @@ use ruma::{
|
||||||
room::power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent},
|
room::power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent},
|
||||||
StateEventType,
|
StateEventType,
|
||||||
},
|
},
|
||||||
OwnedRoomAliasId, OwnedRoomId, OwnedServerName, RoomAliasId, RoomId, UserId,
|
OwnedRoomAliasId, OwnedRoomId, OwnedServerName, RoomAliasId, RoomId, RoomOrAliasId, UserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{appservice::RegistrationInfo, server_is_ours, services};
|
use crate::{appservice::RegistrationInfo, server_is_ours, services};
|
||||||
|
@ -52,6 +52,16 @@ impl Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn resolve(&self, room: &RoomOrAliasId) -> Result<OwnedRoomId> {
|
||||||
|
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")]
|
#[tracing::instrument(skip(self), name = "resolve")]
|
||||||
pub async fn resolve_alias(
|
pub async fn resolve_alias(
|
||||||
&self, room_alias: &RoomAliasId, servers: Option<&Vec<OwnedServerName>>,
|
&self, room_alias: &RoomAliasId, servers: Option<&Vec<OwnedServerName>>,
|
||||||
|
|
Loading…
Add table
Reference in a new issue