mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
refactor: rename min_verified into verified
This commit is contained in:
@@ -94,7 +94,7 @@ impl EncryptHelper {
|
||||
pub async fn encrypt(
|
||||
self,
|
||||
context: &Context,
|
||||
min_verified: bool,
|
||||
verified: bool,
|
||||
mail_to_encrypt: lettre_email::PartBuilder,
|
||||
peerstates: Vec<(Option<Peerstate>, &str)>,
|
||||
) -> Result<String> {
|
||||
@@ -107,7 +107,7 @@ impl EncryptHelper {
|
||||
.filter_map(|(state, addr)| state.clone().map(|s| (s, addr)))
|
||||
{
|
||||
let key = peerstate
|
||||
.take_key(min_verified)
|
||||
.take_key(verified)
|
||||
.with_context(|| format!("proper enc-key for {addr} missing, cannot encrypt"))?;
|
||||
keyring.push(key);
|
||||
verifier_addresses.push(addr);
|
||||
@@ -118,7 +118,7 @@ impl EncryptHelper {
|
||||
|
||||
// Encrypt to secondary verified keys
|
||||
// if we also encrypt to the introducer ("verifier") of the key.
|
||||
if min_verified {
|
||||
if verified {
|
||||
for (peerstate, _addr) in peerstates {
|
||||
if let Some(peerstate) = peerstate {
|
||||
if let (Some(key), Some(verifier)) = (
|
||||
|
||||
@@ -312,7 +312,7 @@ impl<'a> MimeFactory<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn min_verified(&self) -> bool {
|
||||
fn verified(&self) -> bool {
|
||||
match &self.loaded {
|
||||
Loaded::Message { chat } => {
|
||||
if chat.is_protected() {
|
||||
@@ -627,7 +627,7 @@ impl<'a> MimeFactory<'a> {
|
||||
));
|
||||
}
|
||||
|
||||
let min_verified = self.min_verified();
|
||||
let verified = self.verified();
|
||||
let grpimage = self.grpimage();
|
||||
let force_plaintext = self.should_force_plaintext();
|
||||
let skip_autocrypt = self.should_skip_autocrypt();
|
||||
@@ -723,7 +723,7 @@ impl<'a> MimeFactory<'a> {
|
||||
&& self.should_do_gossip(context).await?
|
||||
{
|
||||
for peerstate in peerstates.iter().filter_map(|(state, _)| state.as_ref()) {
|
||||
if let Some(header) = peerstate.render_gossip_header(min_verified) {
|
||||
if let Some(header) = peerstate.render_gossip_header(verified) {
|
||||
message = message.header(Header::new("Autocrypt-Gossip".into(), header));
|
||||
is_gossiped = true;
|
||||
}
|
||||
@@ -756,7 +756,7 @@ impl<'a> MimeFactory<'a> {
|
||||
}
|
||||
|
||||
let encrypted = encrypt_helper
|
||||
.encrypt(context, min_verified, message, peerstates)
|
||||
.encrypt(context, verified, message, peerstates)
|
||||
.await?;
|
||||
|
||||
outer_message
|
||||
|
||||
@@ -362,8 +362,8 @@ impl Peerstate {
|
||||
}
|
||||
|
||||
/// Returns the contents of the `Autocrypt-Gossip` header for outgoing messages.
|
||||
pub fn render_gossip_header(&self, min_verified: bool) -> Option<String> {
|
||||
if let Some(key) = self.peek_key(min_verified) {
|
||||
pub fn render_gossip_header(&self, verified: bool) -> Option<String> {
|
||||
if let Some(key) = self.peek_key(verified) {
|
||||
let header = Aheader::new(
|
||||
self.addr.clone(),
|
||||
key.clone(), // TODO: avoid cloning
|
||||
@@ -386,8 +386,8 @@ impl Peerstate {
|
||||
/// Converts the peerstate into the contact public key.
|
||||
///
|
||||
/// Similar to [`Self::peek_key`], but consumes the peerstate and returns owned key.
|
||||
pub fn take_key(mut self, min_verified: bool) -> Option<SignedPublicKey> {
|
||||
if min_verified {
|
||||
pub fn take_key(mut self, verified: bool) -> Option<SignedPublicKey> {
|
||||
if verified {
|
||||
self.verified_key.take()
|
||||
} else {
|
||||
self.public_key.take().or_else(|| self.gossip_key.take())
|
||||
@@ -396,15 +396,15 @@ impl Peerstate {
|
||||
|
||||
/// Returns a reference to the contact public key.
|
||||
///
|
||||
/// `min_verified` determines the minimum required verification status of the key.
|
||||
/// `verified` determines the required verification status of the key.
|
||||
/// If verified key is requested, returns the verified key,
|
||||
/// otherwise returns the Autocrypt key.
|
||||
///
|
||||
/// Returned key is suitable for sending in `Autocrypt-Gossip` header.
|
||||
///
|
||||
/// Returns `None` if there is no suitable public key.
|
||||
pub fn peek_key(&self, min_verified: bool) -> Option<&SignedPublicKey> {
|
||||
if min_verified {
|
||||
pub fn peek_key(&self, verified: bool) -> Option<&SignedPublicKey> {
|
||||
if verified {
|
||||
self.verified_key.as_ref()
|
||||
} else {
|
||||
self.public_key.as_ref().or(self.gossip_key.as_ref())
|
||||
@@ -414,8 +414,8 @@ impl Peerstate {
|
||||
/// Returns a reference to the contact's public key fingerprint.
|
||||
///
|
||||
/// Similar to [`Self::peek_key`], but returns the fingerprint instead of the key.
|
||||
fn peek_key_fingerprint(&self, min_verified: bool) -> Option<&Fingerprint> {
|
||||
if min_verified {
|
||||
fn peek_key_fingerprint(&self, verified: bool) -> Option<&Fingerprint> {
|
||||
if verified {
|
||||
self.verified_key_fingerprint.as_ref()
|
||||
} else {
|
||||
self.public_key_fingerprint
|
||||
|
||||
Reference in New Issue
Block a user