Skip to content

Commit

Permalink
[identity] Add function to update social proof
Browse files Browse the repository at this point in the history
Summary:
Whitepaper 5.2 says that the social proof needs to be updated for wallet users during the backup restore RPC.
Added a function which updates the social proof value in DDB.

Depends on D13224

Test Plan:
- Registered a wallet user
- Generated new social proof and provided it to the function (manually)
- Verified that DDB contains new social proof value
- Verified that conditional check fails for password users (no previos social proof present)

Reviewers: varun, will

Reviewed By: varun, will

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D13225
  • Loading branch information
barthap committed Sep 9, 2024
1 parent bee39ec commit 9bb32bb
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions services/identity/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,41 @@ impl DatabaseClient {
Ok(())
}

pub async fn update_wallet_user_social_proof(
&self,
user_id: &str,
social_proof: SocialProof,
) -> Result<(), Error> {
self
.client
.update_item()
.table_name(USERS_TABLE)
.key(
USERS_TABLE_PARTITION_KEY,
AttributeValue::S(user_id.to_string()),
)
.update_expression("SET #social_proof = :v")
.condition_expression("attribute_exists(#social_proof)")
.expression_attribute_names(
"#social_proof",
USERS_TABLE_SOCIAL_PROOF_ATTRIBUTE_NAME,
)
.expression_attribute_values(":v", social_proof.into())
.send()
.await
.map_err(|e| {
// ConditionalCheckFailedException means we're updating
// non-wallet user (DB item without social proof)
error!(
errorType = error_types::GENERIC_DB_LOG,
"DynamoDB client failed to update social proof: {:?}", e
);
Error::AwsSdk(e.into())
})?;

Ok(())
}

pub async fn get_keyserver_keys_for_user(
&self,
user_id: &str,
Expand Down

0 comments on commit 9bb32bb

Please sign in to comment.