diff --git a/services/backup/src/constants.rs b/services/backup/src/constants.rs --- a/services/backup/src/constants.rs +++ b/services/backup/src/constants.rs @@ -27,6 +27,7 @@ pub const USER_DATA: &str = "userData"; pub const USER_KEYS: &str = "userKeys"; pub const ATTACHMENTS: &str = "attachments"; + pub const SIWE_BACKUP_MSG: &str = "siweBackupMsg"; } } diff --git a/services/backup/src/database/backup_item.rs b/services/backup/src/database/backup_item.rs --- a/services/backup/src/database/backup_item.rs +++ b/services/backup/src/database/backup_item.rs @@ -3,7 +3,9 @@ use chrono::{DateTime, Utc}; use comm_lib::{ blob::{client::BlobServiceClient, types::BlobInfo}, - database::{AttributeTryInto, DBItemError, TryFromAttribute}, + database::{ + AttributeExtractor, AttributeTryInto, DBItemError, TryFromAttribute, + }, }; use std::collections::HashMap; @@ -15,6 +17,7 @@ pub user_keys: BlobInfo, pub user_data: BlobInfo, pub attachments: Vec, + pub siwe_backup_msg: Option, } impl BackupItem { @@ -24,6 +27,7 @@ user_keys: BlobInfo, user_data: BlobInfo, attachments: Vec, + siwe_backup_msg: Option, ) -> Self { BackupItem { user_id, @@ -32,6 +36,7 @@ user_keys, user_data, attachments, + siwe_backup_msg, } } @@ -109,6 +114,12 @@ ); } + if let Some(siwe_backup_msg_value) = value.siwe_backup_msg { + attrs.insert( + backup_table::attr::SIWE_BACKUP_MSG.to_string(), + AttributeValue::S(siwe_backup_msg_value), + ); + } attrs } } @@ -148,6 +159,9 @@ Vec::new() }; + let siwe_backup_msg: Option = + value.take_attr(backup_table::attr::SIWE_BACKUP_MSG)?; + Ok(BackupItem { user_id, backup_id, @@ -155,6 +169,7 @@ user_keys, user_data, attachments, + 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 @@ -76,12 +76,25 @@ attachments_revokes.push(revoke); } + let siwe_backup_msg_option: Option = + match get_text_field(&mut multipart).await? { + Some((name, siwe_backup_msg)) => { + if name == "siwe_backup_msg" { + Some(siwe_backup_msg) + } else { + None + } + } + _ => None, + }; + let item = BackupItem::new( user.user_id.clone(), backup_id, user_keys_blob_info, user_data_blob_info, attachments, + siwe_backup_msg_option, ); db_client