mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-04-29 03:23:50 -04:00
recovery: comment and simplify all_known_secrets_available
This commit is contained in:
@@ -399,24 +399,27 @@ impl Recovery {
|
||||
Ok(devices.devices().count() == 1)
|
||||
}
|
||||
|
||||
/// Did we correctly set up cross-signing and backups?
|
||||
async fn all_known_secrets_available(&self) -> Result<bool> {
|
||||
// Cross-signing state is fine if we have all the private cross-signing keys, as
|
||||
// indicated in the status.
|
||||
let cross_signing_complete = self
|
||||
.client
|
||||
.encryption()
|
||||
.cross_signing_status()
|
||||
.await
|
||||
.map(|status| status.is_complete())
|
||||
.unwrap_or_default();
|
||||
.map(|status| status.is_complete());
|
||||
if !cross_signing_complete.unwrap_or_default() {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
// The backup state is fine if we have backups enabled locally, or if backups
|
||||
// have been marked as disabled.
|
||||
let backup_state_ok = if self.client.encryption().backups().are_enabled().await {
|
||||
true
|
||||
if self.client.encryption().backups().are_enabled().await {
|
||||
Ok(true)
|
||||
} else {
|
||||
self.are_backups_marked_as_disabled().await?
|
||||
};
|
||||
|
||||
Ok(cross_signing_complete && backup_state_ok)
|
||||
self.are_backups_marked_as_disabled().await
|
||||
}
|
||||
}
|
||||
|
||||
async fn should_auto_enable_backups(&self) -> Result<bool> {
|
||||
@@ -448,6 +451,8 @@ impl Recovery {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Run a network request to figure whether backups have been disabled at
|
||||
/// the account level.
|
||||
async fn are_backups_marked_as_disabled(&self) -> Result<bool> {
|
||||
Ok(self
|
||||
.client
|
||||
|
||||
@@ -176,19 +176,6 @@ async fn recovery_status_secret_storage_set_up() {
|
||||
|
||||
mock_secret_store_with_backup_key(user_id, KEY_ID, &server).await;
|
||||
|
||||
Mock::given(method("GET"))
|
||||
.and(path(format!(
|
||||
"_matrix/client/r0/user/{user_id}/account_data/m.org.matrix.custom.backup_disabled"
|
||||
)))
|
||||
.and(header("authorization", "Bearer 1234"))
|
||||
.respond_with(ResponseTemplate::new(404).set_body_json(json!({
|
||||
"errcode": "M_NOT_FOUND",
|
||||
"error": "Account data not found"
|
||||
})))
|
||||
.expect(1..)
|
||||
.mount(&server)
|
||||
.await;
|
||||
|
||||
client.restore_session(session).await.unwrap();
|
||||
client.encryption().wait_for_e2ee_initialization_tasks().await;
|
||||
|
||||
@@ -724,19 +711,6 @@ async fn recover_and_reset() {
|
||||
|
||||
mock_secret_store_with_backup_key(user_id, KEY_ID, &server).await;
|
||||
|
||||
Mock::given(method("GET"))
|
||||
.and(path(format!(
|
||||
"_matrix/client/r0/user/{user_id}/account_data/m.org.matrix.custom.backup_disabled"
|
||||
)))
|
||||
.and(header("authorization", "Bearer 1234"))
|
||||
.respond_with(ResponseTemplate::new(404).set_body_json(json!({
|
||||
"errcode": "M_NOT_FOUND",
|
||||
"error": "Account data not found"
|
||||
})))
|
||||
.expect(1..)
|
||||
.mount(&server)
|
||||
.await;
|
||||
|
||||
Mock::given(method("GET"))
|
||||
.and(path("_matrix/client/r0/room_keys/version"))
|
||||
.and(header("authorization", "Bearer 1234"))
|
||||
|
||||
Reference in New Issue
Block a user