Struct deltachat::mimeparser::MimeMessage
source · pub(crate) struct MimeMessage {Show 30 fields
pub parts: Vec<Part>,
headers: HashMap<String, String>,
pub recipients: Vec<SingleInfo>,
pub from: SingleInfo,
pub from_is_signed: bool,
pub incoming: bool,
pub list_post: Option<String>,
pub chat_disposition_notification_to: Option<SingleInfo>,
pub autocrypt_header: Option<Aheader>,
pub peerstate: Option<Peerstate>,
pub decrypting_failed: bool,
pub signatures: HashSet<Fingerprint>,
pub gossiped_keys: HashMap<String, SignedPublicKey>,
pub is_forwarded: bool,
pub is_system_message: SystemMessage,
pub location_kml: Option<Kml>,
pub message_kml: Option<Kml>,
pub(crate) sync_items: Option<SyncItems>,
pub(crate) webxdc_status_update: Option<String>,
pub(crate) user_avatar: Option<AvatarAction>,
pub(crate) group_avatar: Option<AvatarAction>,
pub(crate) mdn_reports: Vec<Report>,
pub(crate) delivery_report: Option<DeliveryReport>,
pub(crate) footer: Option<String>,
pub is_mime_modified: bool,
pub decoded_data: Vec<u8>,
pub(crate) hop_info: String,
pub(crate) is_bot: Option<bool>,
pub(crate) timestamp_rcvd: i64,
pub(crate) timestamp_sent: i64,
}
Expand description
A parsed MIME message.
This represents the relevant information of a parsed MIME message for deltachat. The original MIME message might have had more information but this representation should contain everything needed for deltachat’s purposes.
It is created by parsing the raw data of an actual MIME message using the MimeMessage::from_bytes constructor.
Fields§
§parts: Vec<Part>
Parsed MIME parts.
headers: HashMap<String, String>
Message headers.
recipients: Vec<SingleInfo>
Addresses are normalized and lowercase
from: SingleInfo
From:
address.
from_is_signed: bool
Whether the From address was repeated in the signed part (and we know that the signer intended to send from this address)
incoming: bool
Whether the message is incoming or outgoing (self-sent).
list_post: Option<String>
The List-Post address is only set for mailing lists. Users can send messages to this address to post them to the list.
chat_disposition_notification_to: Option<SingleInfo>
§autocrypt_header: Option<Aheader>
§peerstate: Option<Peerstate>
§decrypting_failed: bool
§signatures: HashSet<Fingerprint>
Set of valid signature fingerprints if a message is an Autocrypt encrypted and signed message.
If a message is not encrypted or the signature is not valid, this set is empty.
gossiped_keys: HashMap<String, SignedPublicKey>
The mail recipient addresses for which gossip headers were applied and their respective gossiped keys, regardless of whether they modified any peerstates.
is_forwarded: bool
True if the message is a forwarded message.
is_system_message: SystemMessage
§location_kml: Option<Kml>
§message_kml: Option<Kml>
§sync_items: Option<SyncItems>
§webxdc_status_update: Option<String>
§user_avatar: Option<AvatarAction>
§group_avatar: Option<AvatarAction>
§mdn_reports: Vec<Report>
§delivery_report: Option<DeliveryReport>
Standard USENET signature, if any.
None
means no text part was received, empty string means a text part without a footer is
received.
is_mime_modified: bool
§decoded_data: Vec<u8>
The decrypted, raw mime structure.
This is non-empty iff is_mime_modified
and the message was actually encrypted. It is used
for e.g. late-parsing HTML.
hop_info: String
Hop info for debugging.
is_bot: Option<bool>
Whether the contact sending this should be marked as bot or non-bot.
timestamp_rcvd: i64
When the message was received, in secs since epoch.
timestamp_sent: i64
Sender timestamp in secs since epoch. Allowed to be in the future due to unsynchronized clocks, but not too much.
Implementations§
source§impl MimeMessage
impl MimeMessage
sourcepub(crate) async fn create_stub_from_partial_download(
&mut self,
context: &Context,
org_bytes: u32,
) -> Result<()>
pub(crate) async fn create_stub_from_partial_download( &mut self, context: &Context, org_bytes: u32, ) -> Result<()>
Creates a placeholder part and add that to parts
.
To create the placeholder, only the outermost header can be used, the mime-structure itself is not available.
The placeholder part currently contains a text with size and availability of the message; in the future, we may do more advanced things as previews here.
source§impl MimeMessage
impl MimeMessage
sourcepub(crate) async fn from_bytes(
context: &Context,
body: &[u8],
partial: Option<u32>,
) -> Result<Self>
pub(crate) async fn from_bytes( context: &Context, body: &[u8], partial: Option<u32>, ) -> Result<Self>
Parse a mime message.
If partial
is set, it contains the full message size in bytes
and body
contains the header only.
fn get_timestamp_sent( hdrs: &[MailHeader<'_>], default: i64, timestamp_rcvd: i64, ) -> i64
sourcefn parse_system_message_headers(&mut self, context: &Context)
fn parse_system_message_headers(&mut self, context: &Context)
Parses system messages.
sourceasync fn parse_avatar_headers(&mut self, context: &Context)
async fn parse_avatar_headers(&mut self, context: &Context)
Parses avatar action headers.
fn parse_videochat_headers(&mut self)
sourcefn squash_attachment_parts(&mut self)
fn squash_attachment_parts(&mut self)
Squashes mutitpart chat messages with attachment into single-part messages.
Delta Chat sends attachments, such as images, in two-part messages, with the first message containing a description. If such a message is detected, text from the first part can be moved to the second part, and the first part dropped.
sourcefn parse_attachments(&mut self)
fn parse_attachments(&mut self)
Processes chat messages with attachments.
async fn parse_headers(&mut self, context: &Context) -> Result<()>
async fn avatar_action_from_header( &mut self, context: &Context, header_value: String, ) -> Option<AvatarAction>
sourcepub fn was_encrypted(&self) -> bool
pub fn was_encrypted(&self) -> bool
Returns true if the message was encrypted as defined in Autocrypt standard.
This means the message was both encrypted and signed with a valid signature.
sourcepub(crate) fn has_chat_version(&self) -> bool
pub(crate) fn has_chat_version(&self) -> bool
Returns whether the email contains a chat-version
header.
This indicates that the email is a DC-email.
pub(crate) fn get_subject(&self) -> Option<String>
pub fn get_header(&self, headerdef: HeaderDef) -> Option<&str>
sourcepub fn get_chat_group_id(&self) -> Option<&str>
pub fn get_chat_group_id(&self) -> Option<&str>
Returns Chat-Group-ID
header value if it is a valid group ID.
async fn parse_mime_recursive<'a>( &'a mut self, context: &'a Context, mail: &'a ParsedMail<'a>, is_related: bool, ) -> Result<bool>
async fn handle_multiple( &mut self, context: &Context, mail: &ParsedMail<'_>, is_related: bool, ) -> Result<bool>
sourceasync fn add_single_part_if_known(
&mut self,
context: &Context,
mail: &ParsedMail<'_>,
is_related: bool,
) -> Result<bool>
async fn add_single_part_if_known( &mut self, context: &Context, mail: &ParsedMail<'_>, is_related: bool, ) -> Result<bool>
Returns true if any part was added, false otherwise.
async fn do_add_single_file_part( &mut self, context: &Context, msg_type: Viewtype, mime_type: Mime, raw_mime: &str, decoded_data: &[u8], filename: &str, is_related: bool, ) -> Result<()>
sourceasync fn try_set_peer_key_from_file_part(
context: &Context,
peerstate: &mut Peerstate,
decoded_data: &[u8],
) -> Result<bool>
async fn try_set_peer_key_from_file_part( context: &Context, peerstate: &mut Peerstate, decoded_data: &[u8], ) -> Result<bool>
Returns whether a key from the attachment was set as peer’s pubkey.
fn do_add_single_part(&mut self, part: Part)
pub(crate) fn get_mailinglist_header(&self) -> Option<&str>
pub(crate) fn is_mailinglist_message(&self) -> bool
sourcepub(crate) fn is_schleuder_message(&self) -> bool
pub(crate) fn is_schleuder_message(&self) -> bool
Detects Schleuder mailing list by List-Help header.
pub fn replace_msg_by_error(&mut self, error_msg: &str)
pub(crate) fn get_rfc724_mid(&self) -> Option<String>
fn remove_secured_headers(headers: &mut HashMap<String, String>)
fn merge_headers( context: &Context, headers: &mut HashMap<String, String>, recipients: &mut Vec<SingleInfo>, from: &mut Option<SingleInfo>, list_post: &mut Option<String>, chat_disposition_notification_to: &mut Option<SingleInfo>, fields: &[MailHeader<'_>], )
fn process_report( &self, context: &Context, report: &ParsedMail<'_>, ) -> Result<Option<Report>>
fn process_delivery_status( &self, context: &Context, report: &ParsedMail<'_>, ) -> Result<Option<DeliveryReport>>
fn maybe_remove_bad_parts(&mut self)
Remove unwanted, additional text parts used for mailing list footer. Some mailinglist software add footers as separate mimeparts eg. when the user-edited-content is html. As these footers would appear as repeated, separate text-bubbles, we remove them.
We make an exception for Schleuder mailing lists because they typically create messages with two text parts, one for headers and one for the actual contents.
sourceasync fn heuristically_parse_ndn(&mut self, context: &Context)
async fn heuristically_parse_ndn(&mut self, context: &Context)
Some providers like GMX and Yahoo do not send standard NDNs (Non Delivery notifications). If you improve heuristics here you might also have to change prefetch_should_download() in imap/mod.rs. Also you should add a test in receive_imf.rs (there already are lots of test_parse_ndn_* tests).
sourcepub async fn handle_reports(
&self,
context: &Context,
from_id: ContactId,
parts: &[Part],
)
pub async fn handle_reports( &self, context: &Context, from_id: ContactId, parts: &[Part], )
Handle reports (MDNs = Message Disposition Notification, the message was read and NDNs = Non delivery notification, the message could not be delivered)