Skip to content
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
4 changes: 4 additions & 0 deletions bindings/matrix-sdk-ffi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.

### Breaking changes

- The `Encryption::user_identity()` method has received a new argument. The
`fallback_to_server` argument controls if we should attempt to fetch the user
identity from the homeserver if it wasn't found in the local storage.
([#5870](https://github.com/matrix-org/matrix-rust-sdk/pull/5870))
- Expose the power level required to modify `m.space.child` on
`room::power_levels::RoomPowerLevelsValues`.
- Rename `Client::login_with_qr_code` to `Client::new_login_with_qr_code_handler`.
Expand Down
13 changes: 10 additions & 3 deletions bindings/matrix-sdk-ffi/src/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,13 @@ impl Encryption {
/// This method always tries to fetch the identity from the store, which we
/// only have if the user is tracked, meaning that we are both members
/// of the same encrypted room. If no user is found locally, a request will
/// be made to the homeserver.
/// be made to the homeserver unless `fallback_to_server` is set to `false`.
///
/// # Arguments
///
/// * `user_id` - The ID of the user that the identity belongs to.
/// * `fallback_to_server` - Should we request the user identity from the
/// homeserver if one isn't found locally.
///
/// Returns a `UserIdentity` if one is found. Returns an error if there
/// was an issue with the crypto store or with the request to the
Expand All @@ -448,6 +450,7 @@ impl Encryption {
pub async fn user_identity(
&self,
user_id: String,
fallback_to_server: bool,
) -> Result<Option<Arc<UserIdentity>>, ClientError> {
match self.inner.get_user_identity(user_id.as_str().try_into()?).await {
Ok(Some(identity)) => {
Expand All @@ -463,8 +466,12 @@ impl Encryption {

info!("Requesting identity from the server.");

let identity = self.inner.request_user_identity(user_id.as_str().try_into()?).await?;
Ok(identity.map(|identity| Arc::new(UserIdentity { inner: identity })))
if fallback_to_server {
let identity = self.inner.request_user_identity(user_id.as_str().try_into()?).await?;
Ok(identity.map(|identity| Arc::new(UserIdentity { inner: identity })))
} else {
Ok(None)
}
}
}

Expand Down
Loading