mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 14:36:29 +03:00
feat: support receiving Autocrypt-Gossip with _verified attribute
This commit is a preparation for sending Autocrypt-Gossip with `_verified` attribute instead of `Chat-Verified` header.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//! # MIME message parsing module.
|
||||
|
||||
use std::cmp::min;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::path::Path;
|
||||
use std::str;
|
||||
use std::str::FromStr;
|
||||
@@ -36,6 +36,17 @@ use crate::tools::{
|
||||
};
|
||||
use crate::{chatlist_events, location, stock_str, tools};
|
||||
|
||||
/// Public key extracted from `Autocrypt-Gossip`
|
||||
/// header with associated information.
|
||||
#[derive(Debug)]
|
||||
pub struct GossipedKey {
|
||||
/// Public key extracted from `keydata` attribute.
|
||||
pub public_key: SignedPublicKey,
|
||||
|
||||
/// True if `Autocrypt-Gossip` has a `_verified` attribute.
|
||||
pub verified: bool,
|
||||
}
|
||||
|
||||
/// A parsed MIME message.
|
||||
///
|
||||
/// This represents the relevant information of a parsed MIME message
|
||||
@@ -85,7 +96,7 @@ pub(crate) struct MimeMessage {
|
||||
|
||||
/// The addresses for which there was a gossip header
|
||||
/// and their respective gossiped keys.
|
||||
pub gossiped_keys: HashMap<String, SignedPublicKey>,
|
||||
pub gossiped_keys: BTreeMap<String, GossipedKey>,
|
||||
|
||||
/// Fingerprint of the key in the Autocrypt header.
|
||||
///
|
||||
@@ -1963,9 +1974,9 @@ async fn parse_gossip_headers(
|
||||
from: &str,
|
||||
recipients: &[SingleInfo],
|
||||
gossip_headers: Vec<String>,
|
||||
) -> Result<HashMap<String, SignedPublicKey>> {
|
||||
) -> Result<BTreeMap<String, GossipedKey>> {
|
||||
// XXX split the parsing from the modification part
|
||||
let mut gossiped_keys: HashMap<String, SignedPublicKey> = Default::default();
|
||||
let mut gossiped_keys: BTreeMap<String, GossipedKey> = Default::default();
|
||||
|
||||
for value in &gossip_headers {
|
||||
let header = match value.parse::<Aheader>() {
|
||||
@@ -2007,7 +2018,12 @@ async fn parse_gossip_headers(
|
||||
)
|
||||
.await?;
|
||||
|
||||
gossiped_keys.insert(header.addr.to_lowercase(), header.public_key);
|
||||
let gossiped_key = GossipedKey {
|
||||
public_key: header.public_key,
|
||||
|
||||
verified: header.verified,
|
||||
};
|
||||
gossiped_keys.insert(header.addr.to_lowercase(), gossiped_key);
|
||||
}
|
||||
|
||||
Ok(gossiped_keys)
|
||||
|
||||
Reference in New Issue
Block a user