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:
Simon Farre
2023-04-04 11:04:54 +02:00
committed by GitHub
parent e8c56f8163
commit fc56ae3dcf
2 changed files with 17 additions and 0 deletions

View File

@@ -274,6 +274,9 @@ interface Room {
[Throws=ClientError]
void remove_avatar();
[Throws=ClientError]
void invite_user_by_id(string user_id);
};
callback interface TimelineListener {

View File

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