ffi: Allow creation of a matrix.to link for any room alias.

This commit is contained in:
Doug
2024-04-29 10:43:36 +01:00
committed by Benjamin Bouvier
parent 5e2a2465c9
commit 4618d7ca7d
2 changed files with 11 additions and 2 deletions

View File

@@ -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.

View File

@@ -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)?;