Can set recovery key of user

This commit is contained in:
2025-11-10 08:47:02 +01:00
parent 4a72411d65
commit a23d671376
4 changed files with 32 additions and 1 deletions

View File

@@ -75,6 +75,8 @@ enum MatrixClientError {
WriteSessionFile(std::io::Error),
#[error("Failed to rename device! {0}")]
RenameDevice(matrix_sdk::HttpError),
#[error("Failed to set recovery key! {0}")]
SetRecoveryKey(matrix_sdk::encryption::recovery::RecoveryError),
}
#[derive(serde::Deserialize)]
@@ -338,4 +340,15 @@ impl MatrixClient {
RecoveryState::Incomplete => EncryptionRecoveryState::Incomplete,
}
}
/// Set new encryption key recovery key
pub async fn set_recovery_key(&self, key: &str) -> anyhow::Result<()> {
Ok(self
.client
.encryption()
.recovery()
.recover(key)
.await
.map_err(MatrixClientError::SetRecoveryKey)?)
}
}