Page MenuHomePhabricator

D10221.diff
No OneTemporary

D10221.diff

diff --git a/services/identity/src/database.rs b/services/identity/src/database.rs
--- a/services/identity/src/database.rs
+++ b/services/identity/src/database.rs
@@ -149,15 +149,20 @@
registration_state: UserRegistrationInfo,
password_file: Vec<u8>,
) -> Result<String, Error> {
- self
+ let device_key_upload = registration_state.flattened_device_key_upload;
+ let user_id = self
.add_user_to_users_table(
- registration_state.flattened_device_key_upload,
+ device_key_upload.clone(),
Some((registration_state.username, Blob::new(password_file))),
None,
None,
registration_state.user_id,
)
- .await
+ .await?;
+
+ self.add_device(&user_id, device_key_upload, None).await?;
+
+ Ok(user_id)
}
pub async fn add_wallet_user_to_users_table(
@@ -167,15 +172,22 @@
social_proof: String,
user_id: Option<String>,
) -> Result<String, Error> {
- self
+ let social_proof = Some(social_proof);
+ let user_id = self
.add_user_to_users_table(
- flattened_device_key_upload,
+ flattened_device_key_upload.clone(),
None,
Some(wallet_address),
- Some(social_proof),
+ social_proof.clone(),
user_id,
)
- .await
+ .await?;
+
+ self
+ .add_device(&user_id, flattened_device_key_upload, social_proof)
+ .await?;
+
+ Ok(user_id)
}
async fn add_user_to_users_table(
@@ -250,8 +262,29 @@
user_id: String,
flattened_device_key_upload: FlattenedDeviceKeyUpload,
) -> Result<(), Error> {
+ // add device to the legacy device list
+ self
+ .add_device_to_users_table(
+ user_id.clone(),
+ flattened_device_key_upload.clone(),
+ None,
+ )
+ .await?;
+
+ // add device to the new device list if not exists
+ let device_exists = self
+ .device_exists(
+ user_id.clone(),
+ flattened_device_key_upload.device_id_key.clone(),
+ )
+ .await?;
+
+ if device_exists {
+ return Ok(());
+ }
+
self
- .add_device_to_users_table(user_id, flattened_device_key_upload, None)
+ .add_device(user_id, flattened_device_key_upload, None)
.await
}
@@ -261,12 +294,30 @@
flattened_device_key_upload: FlattenedDeviceKeyUpload,
social_proof: String,
) -> Result<(), Error> {
+ // add device to the legacy device list
self
.add_device_to_users_table(
- user_id,
- flattened_device_key_upload,
- Some(social_proof),
+ user_id.clone(),
+ flattened_device_key_upload.clone(),
+ Some(social_proof.clone()),
)
+ .await?;
+
+ // add device to the new device list if not exists
+ let device_exists = self
+ .device_exists(
+ user_id.clone(),
+ flattened_device_key_upload.device_id_key.clone(),
+ )
+ .await?;
+
+ if device_exists {
+ return Ok(());
+ }
+
+ // add device to the new device list
+ self
+ .add_device(user_id, flattened_device_key_upload, Some(social_proof))
.await
}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 4:26 AM (20 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2610205
Default Alt Text
D10221.diff (3 KB)

Event Timeline