mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-11 17:33:51 -04:00
ffi: Allow creation of a matrix.to link for any room alias.
This commit is contained in:
@@ -18,7 +18,7 @@ use ruma::{
|
||||
},
|
||||
TimelineEventType,
|
||||
},
|
||||
EventId, Int, UserId,
|
||||
EventId, Int, RoomAliasId, UserId,
|
||||
};
|
||||
use tokio::sync::RwLock;
|
||||
use tracing::error;
|
||||
@@ -667,6 +667,15 @@ impl Room {
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates a `matrix.to` permalink to the given room alias.
|
||||
#[uniffi::export]
|
||||
pub fn matrix_to_room_alias_permalink(
|
||||
room_alias: String,
|
||||
) -> std::result::Result<String, ClientError> {
|
||||
let room_alias = RoomAliasId::parse(room_alias)?;
|
||||
Ok(room_alias.matrix_to_uri().to_string())
|
||||
}
|
||||
|
||||
#[derive(uniffi::Record)]
|
||||
pub struct RoomPowerLevels {
|
||||
/// The level required to ban a user.
|
||||
|
||||
@@ -54,7 +54,7 @@ pub fn suggested_power_level_for_role(role: RoomMemberRole) -> i64 {
|
||||
role.suggested_power_level()
|
||||
}
|
||||
|
||||
/// Generates a `matrix.to` permalink from to the given userID.
|
||||
/// Generates a `matrix.to` permalink to the given userID.
|
||||
#[uniffi::export]
|
||||
pub fn matrix_to_user_permalink(user_id: String) -> Result<String, ClientError> {
|
||||
let user_id = UserId::parse(user_id)?;
|
||||
|
||||
Reference in New Issue
Block a user