Page MenuHomePhabricator

D14072.id46237.diff
No OneTemporary

D14072.id46237.diff

diff --git a/services/identity/src/comm_service/backup.rs b/services/identity/src/comm_service/backup.rs
--- a/services/identity/src/comm_service/backup.rs
+++ b/services/identity/src/comm_service/backup.rs
@@ -44,3 +44,41 @@
}
Ok(())
}
+
+pub async fn user_has_backup(
+ user_identifier: &str,
+) -> Result<bool, crate::error::Error> {
+ let path = format!("/backups/latest/{user_identifier}/backup_info");
+ let url = CONFIG
+ .backup_service_url
+ .join(&path)
+ .expect("failed to construct backup service URL");
+
+ let client = reqwest::Client::builder().build()?;
+ let response = client.get(url).send().await?;
+
+ use http::StatusCode;
+ match response.status() {
+ StatusCode::OK => Ok(true), // Backup service returned backup info
+ StatusCode::NOT_FOUND => Ok(false), // Backup service returned BackupError::NoBackup
+ StatusCode::BAD_REQUEST => {
+ // Identity has no user with given UserIdentifier
+ Err(crate::error::Error::MissingItem)
+ }
+ response_status => {
+ let response_body = response
+ .text()
+ .await
+ .unwrap_or("[failed to get response text]".to_string());
+ tracing::error!(
+ errorType = error_types::HTTP_LOG,
+ "Backup service failed to get latest backup info: {} - {}",
+ response_status,
+ response_body,
+ );
+ Err(
+ tonic::Status::aborted(tonic_status_messages::UNEXPECTED_ERROR).into(),
+ )
+ }
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 9, 2:51 AM (4 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2826248
Default Alt Text
D14072.id46237.diff (1 KB)

Event Timeline