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)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MimeMessage
impl RefUnwindSafe for MimeMessage
impl Send for MimeMessage
impl Sync for MimeMessage
impl Unpin for MimeMessage
impl UnwindSafe for MimeMessage
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
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) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
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
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.