Skip to content

Commit 1c9662a

Browse files
committed
refactor: rename min_verified into verified
1 parent 5d08b2c commit 1c9662a

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/e2ee.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl EncryptHelper {
9494
pub async fn encrypt(
9595
self,
9696
context: &Context,
97-
min_verified: bool,
97+
verified: bool,
9898
mail_to_encrypt: lettre_email::PartBuilder,
9999
peerstates: Vec<(Option<Peerstate>, &str)>,
100100
) -> Result<String> {
@@ -107,7 +107,7 @@ impl EncryptHelper {
107107
.filter_map(|(state, addr)| state.clone().map(|s| (s, addr)))
108108
{
109109
let key = peerstate
110-
.take_key(min_verified)
110+
.take_key(verified)
111111
.with_context(|| format!("proper enc-key for {addr} missing, cannot encrypt"))?;
112112
keyring.push(key);
113113
verifier_addresses.push(addr);
@@ -118,7 +118,7 @@ impl EncryptHelper {
118118

119119
// Encrypt to secondary verified keys
120120
// if we also encrypt to the introducer ("verifier") of the key.
121-
if min_verified {
121+
if verified {
122122
for (peerstate, _addr) in peerstates {
123123
if let Some(peerstate) = peerstate {
124124
if let (Some(key), Some(verifier)) = (

src/mimefactory.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'a> MimeFactory<'a> {
312312
}
313313
}
314314

315-
fn min_verified(&self) -> bool {
315+
fn verified(&self) -> bool {
316316
match &self.loaded {
317317
Loaded::Message { chat } => {
318318
if chat.is_protected() {
@@ -627,7 +627,7 @@ impl<'a> MimeFactory<'a> {
627627
));
628628
}
629629

630-
let min_verified = self.min_verified();
630+
let verified = self.verified();
631631
let grpimage = self.grpimage();
632632
let force_plaintext = self.should_force_plaintext();
633633
let skip_autocrypt = self.should_skip_autocrypt();
@@ -723,7 +723,7 @@ impl<'a> MimeFactory<'a> {
723723
&& self.should_do_gossip(context).await?
724724
{
725725
for peerstate in peerstates.iter().filter_map(|(state, _)| state.as_ref()) {
726-
if let Some(header) = peerstate.render_gossip_header(min_verified) {
726+
if let Some(header) = peerstate.render_gossip_header(verified) {
727727
message = message.header(Header::new("Autocrypt-Gossip".into(), header));
728728
is_gossiped = true;
729729
}
@@ -756,7 +756,7 @@ impl<'a> MimeFactory<'a> {
756756
}
757757

758758
let encrypted = encrypt_helper
759-
.encrypt(context, min_verified, message, peerstates)
759+
.encrypt(context, verified, message, peerstates)
760760
.await?;
761761

762762
outer_message

src/peerstate.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ impl Peerstate {
362362
}
363363

364364
/// Returns the contents of the `Autocrypt-Gossip` header for outgoing messages.
365-
pub fn render_gossip_header(&self, min_verified: bool) -> Option<String> {
366-
if let Some(key) = self.peek_key(min_verified) {
365+
pub fn render_gossip_header(&self, verified: bool) -> Option<String> {
366+
if let Some(key) = self.peek_key(verified) {
367367
let header = Aheader::new(
368368
self.addr.clone(),
369369
key.clone(), // TODO: avoid cloning
@@ -386,8 +386,8 @@ impl Peerstate {
386386
/// Converts the peerstate into the contact public key.
387387
///
388388
/// Similar to [`Self::peek_key`], but consumes the peerstate and returns owned key.
389-
pub fn take_key(mut self, min_verified: bool) -> Option<SignedPublicKey> {
390-
if min_verified {
389+
pub fn take_key(mut self, verified: bool) -> Option<SignedPublicKey> {
390+
if verified {
391391
self.verified_key.take()
392392
} else {
393393
self.public_key.take().or_else(|| self.gossip_key.take())
@@ -396,15 +396,15 @@ impl Peerstate {
396396

397397
/// Returns a reference to the contact public key.
398398
///
399-
/// `min_verified` determines the minimum required verification status of the key.
399+
/// `verified` determines the required verification status of the key.
400400
/// If verified key is requested, returns the verified key,
401401
/// otherwise returns the Autocrypt key.
402402
///
403403
/// Returned key is suitable for sending in `Autocrypt-Gossip` header.
404404
///
405405
/// Returns `None` if there is no suitable public key.
406-
pub fn peek_key(&self, min_verified: bool) -> Option<&SignedPublicKey> {
407-
if min_verified {
406+
pub fn peek_key(&self, verified: bool) -> Option<&SignedPublicKey> {
407+
if verified {
408408
self.verified_key.as_ref()
409409
} else {
410410
self.public_key.as_ref().or(self.gossip_key.as_ref())
@@ -414,8 +414,8 @@ impl Peerstate {
414414
/// Returns a reference to the contact's public key fingerprint.
415415
///
416416
/// Similar to [`Self::peek_key`], but returns the fingerprint instead of the key.
417-
fn peek_key_fingerprint(&self, min_verified: bool) -> Option<&Fingerprint> {
418-
if min_verified {
417+
fn peek_key_fingerprint(&self, verified: bool) -> Option<&Fingerprint> {
418+
if verified {
419419
self.verified_key_fingerprint.as_ref()
420420
} else {
421421
self.public_key_fingerprint

0 commit comments

Comments
 (0)