Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFI: Allow the creation of a matrix.to link for any room alias. #3358

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 10 additions & 1 deletion bindings/matrix-sdk-ffi/src/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use ruma::{
},
TimelineEventType,
},
EventId, Int, UserId,
EventId, Int, RoomAliasId, UserId,
};
use tokio::sync::RwLock;
use tracing::error;
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion bindings/matrix-sdk-ffi/src/room_member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
Loading