feat: map application details

This commit is contained in:
Sebastian Pravda 2022-12-14 17:10:00 +01:00
parent 7bce4bf0bc
commit e5e91aff9a
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57

View file

@ -245,12 +245,10 @@ impl EncryptedApplicationDetails {
recipients: Vec<String>, recipients: Vec<String>,
) -> Result<EncryptedApplicationDetails, ServiceError> { ) -> Result<EncryptedApplicationDetails, ServiceError> {
let candidate = EncryptedCandidateDetails::new(&form.candidate, &recipients).await?; let candidate = EncryptedCandidateDetails::new(&form.candidate, &recipients).await?;
let mut enc_parents= vec![]; let enc_parents = future::try_join_all(
for parent in form.parents.iter() { form.parents.iter()
enc_parents.push( .map(|d| EncryptedParentDetails::new(d, &recipients))
EncryptedParentDetails::new(parent, &recipients).await? ).await?;
);
}
Ok( Ok(
EncryptedApplicationDetails { EncryptedApplicationDetails {
candidate, candidate,
@ -282,12 +280,10 @@ impl TryFrom<(candidate::Model, Vec<parent::Model>)> for EncryptedApplicationDet
fn try_from( fn try_from(
(candidate, parents): (candidate::Model, Vec<parent::Model>), (candidate, parents): (candidate::Model, Vec<parent::Model>),
) -> Result<Self, Self::Error> { ) -> Result<Self, Self::Error> {
let mut enc_parents = vec![]; let enc_parents = parents.iter()
for parent in parents.iter() { .map(|m| EncryptedParentDetails::try_from(m.clone()))
enc_parents.push( .collect::<Result<Vec<EncryptedParentDetails>, ServiceError>>()?;
EncryptedParentDetails::try_from(parent.clone())?
);
}
Ok(EncryptedApplicationDetails { Ok(EncryptedApplicationDetails {
candidate: EncryptedCandidateDetails::try_from(candidate)?, candidate: EncryptedCandidateDetails::try_from(candidate)?,
parents: enc_parents, parents: enc_parents,