Page MenuHomePhabricator

D13809.diff
No OneTemporary

D13809.diff

diff --git a/native/native_rust_library/src/backup.rs b/native/native_rust_library/src/backup.rs
--- a/native/native_rust_library/src/backup.rs
+++ b/native/native_rust_library/src/backup.rs
@@ -15,7 +15,7 @@
use crate::BACKUP_SOCKET_ADDR;
use crate::RUNTIME;
use backup_client::{
- BackupClient, BackupDescriptor, LatestBackupIDResponse, RequestedData,
+ BackupClient, BackupDescriptor, LatestBackupInfoResponse, RequestedData,
TryStreamExt, UserIdentity,
};
use serde::{Deserialize, Serialize};
@@ -216,8 +216,9 @@
}
};
- let LatestBackupIDResponse {
+ let LatestBackupInfoResponse {
backup_id,
+ user_id,
siwe_backup_msg,
} = result;
@@ -326,7 +327,7 @@
}
async fn download_latest_backup_id(
-) -> Result<LatestBackupIDResponse, Box<dyn Error>> {
+) -> Result<LatestBackupInfoResponse, Box<dyn Error>> {
let backup_client = BackupClient::new(BACKUP_SOCKET_ADDR)?;
let user_identity = get_user_identity_from_secure_store()?;
@@ -334,17 +335,19 @@
user_identifier: user_identity.user_id.clone(),
};
- let backup_id_response = backup_client
- .download_backup_data(&latest_backup_descriptor, RequestedData::BackupID)
+ let backup_info_response = backup_client
+ .download_backup_data(&latest_backup_descriptor, RequestedData::BackupInfo)
.await?;
- let LatestBackupIDResponse {
+ let LatestBackupInfoResponse {
backup_id,
+ user_id,
siwe_backup_msg,
- } = serde_json::from_slice(&backup_id_response)?;
+ } = serde_json::from_slice(&backup_info_response)?;
- Ok(LatestBackupIDResponse {
+ Ok(LatestBackupInfoResponse {
backup_id,
+ user_id,
siwe_backup_msg,
})
}
diff --git a/services/backup/src/http/handlers/backup.rs b/services/backup/src/http/handlers/backup.rs
--- a/services/backup/src/http/handlers/backup.rs
+++ b/services/backup/src/http/handlers/backup.rs
@@ -5,7 +5,7 @@
};
use comm_lib::{
auth::UserIdentity,
- backup::LatestBackupIDResponse,
+ backup::LatestBackupInfoResponse,
blob::{client::BlobServiceClient, types::BlobInfo},
http::{
auth_service::Authenticated,
@@ -278,7 +278,7 @@
}
#[instrument(skip_all, fields(username = %path))]
-pub async fn get_latest_backup_id(
+pub async fn get_latest_backup_info(
path: web::Path<String>,
db_client: web::Data<DatabaseClient>,
) -> actix_web::Result<impl Responder> {
@@ -293,8 +293,9 @@
return Err(BackupError::NoBackup.into());
};
- let response = LatestBackupIDResponse {
+ let response = LatestBackupInfoResponse {
backup_id: backup_item.backup_id,
+ user_id,
siwe_backup_msg: backup_item.siwe_backup_msg,
};
diff --git a/services/backup/src/http/mod.rs b/services/backup/src/http/mod.rs
--- a/services/backup/src/http/mod.rs
+++ b/services/backup/src/http/mod.rs
@@ -41,8 +41,8 @@
// Backup services that don't require authetication
web::scope("/backups/latest")
.service(
- web::resource("{user_identifier}/backup_id")
- .route(web::get().to(handlers::backup::get_latest_backup_id)),
+ web::resource("{user_identifier}/backup_info")
+ .route(web::get().to(handlers::backup::get_latest_backup_info)),
)
.service(web::resource("{user_identifier}/user_keys").route(
web::get().to(handlers::backup::download_latest_backup_keys),
diff --git a/services/commtest/tests/backup_integration_test.rs b/services/commtest/tests/backup_integration_test.rs
--- a/services/commtest/tests/backup_integration_test.rs
+++ b/services/commtest/tests/backup_integration_test.rs
@@ -6,7 +6,7 @@
use bytesize::ByteSize;
use comm_lib::{
auth::UserIdentity,
- backup::{LatestBackupIDResponse, UploadLogRequest},
+ backup::{LatestBackupInfoResponse, UploadLogRequest},
};
use commtest::identity::device::register_user_device;
use commtest::{
@@ -81,7 +81,7 @@
};
let nonexistent_user_response = backup_client
- .download_backup_data(&latest_backup_descriptor, RequestedData::BackupID)
+ .download_backup_data(&latest_backup_descriptor, RequestedData::BackupInfo)
.await;
match nonexistent_user_response {
@@ -101,12 +101,13 @@
user_identifier: device_info.username,
};
- let backup_id_response = backup_client
- .download_backup_data(&latest_backup_descriptor, RequestedData::BackupID)
+ let backup_info_response = backup_client
+ .download_backup_data(&latest_backup_descriptor, RequestedData::BackupInfo)
.await?;
- let response: LatestBackupIDResponse =
- serde_json::from_slice(&backup_id_response)?;
+ let response: LatestBackupInfoResponse =
+ serde_json::from_slice(&backup_info_response)?;
assert_eq!(response.backup_id, backup_data.backup_id);
+ assert_eq!(response.user_id, device_info.user_id);
let user_keys = backup_client
.download_backup_data(&latest_backup_descriptor, RequestedData::UserKeys)
diff --git a/services/commtest/tests/backup_performance_test.rs b/services/commtest/tests/backup_performance_test.rs
--- a/services/commtest/tests/backup_performance_test.rs
+++ b/services/commtest/tests/backup_performance_test.rs
@@ -2,7 +2,7 @@
BackupClient, BackupData, BackupDescriptor, RequestedData,
};
use bytesize::ByteSize;
-use comm_lib::{auth::UserIdentity, backup::LatestBackupIDResponse};
+use comm_lib::{auth::UserIdentity, backup::LatestBackupInfoResponse};
use commtest::identity::device::register_user_device;
use commtest::{
service_addr,
@@ -92,11 +92,11 @@
handlers.push(tokio::spawn(async move {
let response = backup_client
- .download_backup_data(&descriptor, RequestedData::BackupID)
+ .download_backup_data(&descriptor, RequestedData::BackupInfo)
.await
.unwrap();
- serde_json::from_slice::<LatestBackupIDResponse>(&response).unwrap()
+ serde_json::from_slice::<LatestBackupInfoResponse>(&response).unwrap()
}));
}
diff --git a/shared/backup_client/src/lib.rs b/shared/backup_client/src/lib.rs
--- a/shared/backup_client/src/lib.rs
+++ b/shared/backup_client/src/lib.rs
@@ -4,7 +4,7 @@
use async_stream::{stream, try_stream};
pub use comm_lib::auth::UserIdentity;
pub use comm_lib::backup::{
- DownloadLogsRequest, LatestBackupIDResponse, LogWSRequest, LogWSResponse,
+ DownloadLogsRequest, LatestBackupInfoResponse, LogWSRequest, LogWSResponse,
UploadLogRequest,
};
pub use futures_util::{Sink, SinkExt, Stream, StreamExt, TryStreamExt};
@@ -103,7 +103,7 @@
}
};
let url = match &requested_data {
- RequestedData::BackupID => url.join("backup_id")?,
+ RequestedData::BackupInfo => url.join("backup_info")?,
RequestedData::UserKeys => url.join("user_keys")?,
RequestedData::UserData => url.join("user_data")?,
};
@@ -342,7 +342,7 @@
#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
#[derive(Debug, Clone)]
pub enum RequestedData {
- BackupID,
+ BackupInfo,
UserKeys,
UserData,
}
diff --git a/shared/comm-lib/src/backup/mod.rs b/shared/comm-lib/src/backup/mod.rs
--- a/shared/comm-lib/src/backup/mod.rs
+++ b/shared/comm-lib/src/backup/mod.rs
@@ -3,10 +3,11 @@
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
-pub struct LatestBackupIDResponse {
+pub struct LatestBackupInfoResponse {
#[serde(rename = "backupID")]
pub backup_id: String,
-
+ #[serde(rename = "userID")]
+ pub user_id: String,
pub siwe_backup_msg: Option<String>,
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 5:57 AM (19 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2556402
Default Alt Text
D13809.diff (7 KB)

Event Timeline