Skip to content

Commit

Permalink
encryption: Log when the backup and recovery state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
poljar committed Jul 1, 2024
1 parent a819dd5 commit 9e4164f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions crates/matrix-sdk/src/encryption/backups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,12 @@ impl Backups {
}

/// Set the state of the backup.
fn set_state(&self, state: BackupState) {
self.client.inner.e2ee.backup_state.global_state.set(state);
fn set_state(&self, new_state: BackupState) {
let old_state = self.client.inner.e2ee.backup_state.global_state.set(new_state);

if old_state != new_state {
info!("Backup state changed from {old_state:?} to {new_state:?}");
}
}

/// Set the backup state to the `Enabled` variant and insert the backup key
Expand Down Expand Up @@ -860,6 +864,7 @@ impl Backups {

/// Listen for `m.secret.send` to-device messages and check the secret inbox
/// if we do receive one.
#[instrument(skip_all)]
pub(crate) async fn secret_send_event_handler(_: ToDeviceSecretSendEvent, client: Client) {
let olm_machine = client.olm_machine().await;

Expand Down
6 changes: 5 additions & 1 deletion crates/matrix-sdk/src/encryption/recovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,11 @@ impl Recovery {

async fn update_recovery_state(&self) -> Result<()> {
let new_state = self.check_recovery_state().await?;
self.client.inner.e2ee.recovery_state.set(new_state);
let old_state = self.client.inner.e2ee.recovery_state.set(new_state);

if new_state != old_state {
info!("Recovery state changed from {old_state:?} to {new_state:?}");
}

Ok(())
}
Expand Down

0 comments on commit 9e4164f

Please sign in to comment.