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 MSG_BACKUP: &str = "msgBackup"; } } 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 @@ -15,6 +15,7 @@ pub user_keys: BlobInfo, pub user_data: BlobInfo, pub attachments: Vec, + pub msg_backup: Option, } impl BackupItem { @@ -24,6 +25,7 @@ user_keys: BlobInfo, user_data: BlobInfo, attachments: Vec, + msg_backup: Option, ) -> Self { BackupItem { user_id, @@ -32,6 +34,7 @@ user_keys, user_data, attachments, + msg_backup, } } @@ -109,6 +112,12 @@ ); } + if let Some(msg_backup_value) = value.msg_backup { + attrs.insert( + backup_table::attr::MSG_BACKUP.to_string(), + AttributeValue::S(msg_backup_value), + ); + } attrs } } @@ -148,6 +157,16 @@ Vec::new() }; + let msg_backup = value.remove(backup_table::attr::MSG_BACKUP); + let msg_backup = if msg_backup.is_some() { + Some(String::try_from_attr( + backup_table::attr::MSG_BACKUP, + msg_backup, + )?) + } else { + None + }; + Ok(BackupItem { user_id, backup_id, @@ -155,6 +174,7 @@ user_keys, user_data, attachments, + msg_backup, }) } } @@ -195,6 +215,7 @@ Ok(OrderedBackupItem { user_id, + created, backup_id, user_keys, 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 msg_backup_option: Option = + match get_text_field(&mut multipart).await.unwrap() { + Some((name, msg_backup)) => { + if name == "msg_backup" { + Some(msg_backup) + } else { + None + } + } + _ => None, + }; + let item = BackupItem::new( user.user_id.clone(), backup_id, user_keys_blob_info, user_data_blob_info, attachments, + msg_backup_option, ); db_client