deltachat::mimeparser

Struct 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>§footer: Option<String>

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

If set, this is a modified MIME message; clients should offer a way to view the original MIME message in this case.

§decoded_data: Vec<u8>

Decrypted, raw MIME structure. Nonempty iff is_mime_modified and the message was actually encrypted.

§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

source

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

source

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.

source

fn get_timestamp_sent( hdrs: &[MailHeader<'_>], default: i64, timestamp_rcvd: i64, ) -> i64

source

fn parse_system_message_headers(&mut self, context: &Context)

Parses system messages.

source

async fn parse_avatar_headers(&mut self, context: &Context)

Parses avatar action headers.

source

fn parse_videochat_headers(&mut self)

source

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.

source

fn parse_attachments(&mut self)

Processes chat messages with attachments.

source

async fn parse_headers(&mut self, context: &Context) -> Result<()>

source

async fn avatar_action_from_header( &mut self, context: &Context, header_value: String, ) -> Option<AvatarAction>

source

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.

source

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.

source

pub(crate) fn get_subject(&self) -> Option<String>

source

pub fn get_header(&self, headerdef: HeaderDef) -> Option<&str>

source

pub fn get_chat_group_id(&self) -> Option<&str>

Returns Chat-Group-ID header value if it is a valid group ID.

source

async fn parse_mime_recursive<'a>( &'a mut self, context: &'a Context, mail: &'a ParsedMail<'a>, is_related: bool, ) -> Result<bool>

source

async fn handle_multiple( &mut self, context: &Context, mail: &ParsedMail<'_>, is_related: bool, ) -> Result<bool>

source

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.

source

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<()>

source

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.

source

fn do_add_single_part(&mut self, part: Part)

source

pub(crate) fn get_mailinglist_header(&self) -> Option<&str>

source

pub(crate) fn is_mailinglist_message(&self) -> bool

source

pub(crate) fn is_schleuder_message(&self) -> bool

Detects Schleuder mailing list by List-Help header.

source

pub fn replace_msg_by_error(&mut self, error_msg: &str)

source

pub(crate) fn get_rfc724_mid(&self) -> Option<String>

source

fn remove_secured_headers(headers: &mut HashMap<String, String>)

source

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<'_>], )

source

fn process_report( &self, context: &Context, report: &ParsedMail<'_>, ) -> Result<Option<Report>>

source

fn process_delivery_status( &self, context: &Context, report: &ParsedMail<'_>, ) -> Result<Option<DeliveryReport>>

source

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.

source

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).

source

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)

source

pub async fn get_parent_timestamp( &self, context: &Context, ) -> Result<Option<i64>>

Returns timestamp of the parent message.

If there is no parent message or it is not found in the database, returns None.

Trait Implementations§

source§

impl Debug for MimeMessage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T