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>§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§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

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
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. 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.

§

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

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
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