Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3708369
D14072.id46237.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D14072.id46237.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D14072: [identity] Add function to check if user has backup
Attached
Detach File
Event Timeline
Log In to Comment