Skip to content

Commit

Permalink
fixup! ffi: Expose the master_key method on UserIdentity
Browse files Browse the repository at this point in the history
Return options from get_user_identity and master_key
  • Loading branch information
andybalaam committed Oct 7, 2024
1 parent f144db4 commit 562316c
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions bindings/matrix-sdk-ffi/src/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,19 +413,16 @@ impl Encryption {

/// Get the E2EE identity of a user.
///
/// Returns an error if this user does not exist, if there is an error
/// contacting the crypto store, or if our client is not logged in.
/// Returns Ok(None) if this user does not exist.
///
/// Returns an error if there was a problem contacting the crypto store, or
/// if our client is not logged in.
pub async fn get_user_identity(
&self,
user_id: String,
) -> Result<Arc<UserIdentity>, ClientError> {
Ok(Arc::new(UserIdentity {
inner: self
.inner
.get_user_identity(user_id.as_str().try_into()?)
.await?
.ok_or(ClientError::new("User not found"))?,
}))
) -> Result<Option<Arc<UserIdentity>>, ClientError> {
let identity = self.inner.get_user_identity(user_id.as_str().try_into()?).await?;
Ok(identity.map(|i| Arc::new(UserIdentity { inner: i })))
}
}

Expand Down Expand Up @@ -459,13 +456,10 @@ impl UserIdentity {
///
/// The public part of the Master key is usually used to uniquely identify
/// the identity.
pub(crate) fn master_key(&self) -> Result<String, ClientError> {
Ok(self
.inner
.master_key()
.get_first_key()
.ok_or(ClientError::new("Missing master key"))?
.to_base64())
///
/// Returns None if the master key does not actually contain any keys.
pub(crate) fn master_key(&self) -> Option<String> {
self.inner.master_key().get_first_key().map(|k| k.to_base64())
}
}

Expand Down

0 comments on commit 562316c

Please sign in to comment.