mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-07 07:27:45 -04:00
Expose invite_user_by_id over the FFI
This PR is self explanatory. Exposes said function to the FFI. Defined in the .adl file, and defined to throw `ClientError` Signed-off-by: Simon Farre <simon.farre.cx@gmail.com> Co-authored-by: Damir Jelić <poljar@termina.org.uk>
This commit is contained in:
@@ -274,6 +274,9 @@ interface Room {
|
||||
|
||||
[Throws=ClientError]
|
||||
void remove_avatar();
|
||||
|
||||
[Throws=ClientError]
|
||||
void invite_user_by_id(string user_id);
|
||||
};
|
||||
|
||||
callback interface TimelineListener {
|
||||
|
||||
@@ -554,6 +554,20 @@ impl Room {
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn invite_user_by_id(&self, user_id: String) -> Result<()> {
|
||||
let room = match &self.room {
|
||||
SdkRoom::Joined(joined_room) => joined_room.clone(),
|
||||
_ => bail!("Can't invite user to room that isn't in joined state"),
|
||||
};
|
||||
|
||||
RUNTIME.block_on(async move {
|
||||
let user = <&UserId>::try_from(user_id.as_str())
|
||||
.context("Could not create user from string")?;
|
||||
room.invite_user_by_id(user).await?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for Room {
|
||||
|
||||
Reference in New Issue
Block a user