Transpose if branches

This removes three ifs and adds two ifs, making it more clear that
nothing is done if there is no Autocrypt header.
This commit is contained in:
Alexander Krotov
2020-09-06 09:38:04 +03:00
committed by link2xt
parent f7897d5f1a
commit b0bb0214c0

View File

@@ -135,19 +135,19 @@ pub async fn try_decrypt(
.map(|from| from.addr) .map(|from| from.addr)
.unwrap_or_default(); .unwrap_or_default();
// Apply Autocrypt header
let autocryptheader = Aheader::from_headers(context, &from, &mail.headers);
let mut peerstate = Peerstate::from_addr(context, &from).await?; let mut peerstate = Peerstate::from_addr(context, &from).await?;
// Apply Autocrypt header
if let Some(ref header) = Aheader::from_headers(context, &from, &mail.headers) {
if let Some(ref mut peerstate) = peerstate { if let Some(ref mut peerstate) = peerstate {
if let Some(ref header) = autocryptheader {
peerstate.apply_header(&header, message_time); peerstate.apply_header(&header, message_time);
peerstate.save_to_db(&context.sql, false).await?; peerstate.save_to_db(&context.sql, false).await?;
} } else {
} else if let Some(ref header) = autocryptheader {
let p = Peerstate::from_header(context, header, message_time); let p = Peerstate::from_header(context, header, message_time);
p.save_to_db(&context.sql, true).await?; p.save_to_db(&context.sql, true).await?;
peerstate = Some(p); peerstate = Some(p);
} }
}
// Possibly perform decryption // Possibly perform decryption
let private_keyring: Keyring<SignedSecretKey> = Keyring::new_self(context).await?; let private_keyring: Keyring<SignedSecretKey> = Keyring::new_self(context).await?;