Skip to content

Commit

Permalink
ffi: Allow recovery to be enabled using a passphrase
Browse files Browse the repository at this point in the history
  • Loading branch information
poljar committed Sep 27, 2024
1 parent 9b7f89c commit e61fb45
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bindings/matrix-sdk-ffi/src/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ impl Encryption {
pub async fn enable_recovery(
&self,
wait_for_backups_to_upload: bool,
mut passphrase: Option<String>,
progress_listener: Box<dyn EnableRecoveryProgressListener>,
) -> Result<String> {
let recovery = self.inner.recovery();
Expand All @@ -325,6 +326,12 @@ impl Encryption {
recovery.enable()
};

let enable = if let Some(passphrase) = &passphrase {
enable.with_passphrase(passphrase)
} else {
enable
};

let mut progress_stream = enable.subscribe_to_progress();

let task = RUNTIME.spawn(async move {
Expand All @@ -337,6 +344,7 @@ impl Encryption {
let ret = enable.await?;

task.abort();
passphrase.zeroize();

Ok(ret)
}
Expand Down

0 comments on commit e61fb45

Please sign in to comment.