mirror of
https://github.com/chatmail/core.git
synced 2026-05-14 04:16:30 +03:00
Create entries in msgs table for MDNs
At least one entry is required for DeleteMsgOnImap job. Additionally, adding a hidden entry makes it possible to avoid redownloading the message if it gets a new UID on the server.
This commit is contained in:
@@ -624,10 +624,13 @@ fn add_parts(
|
|||||||
let subject = mime_parser.get_subject().unwrap_or_default();
|
let subject = mime_parser.get_subject().unwrap_or_default();
|
||||||
|
|
||||||
for part in mime_parser.parts.iter_mut() {
|
for part in mime_parser.parts.iter_mut() {
|
||||||
if mime_parser.location_kml.is_some()
|
let is_mdn = !mime_parser.reports.is_empty();
|
||||||
|
|
||||||
|
let is_location_kml = mime_parser.location_kml.is_some()
|
||||||
&& icnt == 1
|
&& icnt == 1
|
||||||
&& (part.msg == "-location-" || part.msg.is_empty())
|
&& (part.msg == "-location-" || part.msg.is_empty());
|
||||||
{
|
|
||||||
|
if is_mdn || is_location_kml {
|
||||||
*hidden = true;
|
*hidden = true;
|
||||||
if state == MessageState::InFresh {
|
if state == MessageState::InFresh {
|
||||||
state = MessageState::InNoticed;
|
state = MessageState::InNoticed;
|
||||||
|
|||||||
@@ -544,6 +544,16 @@ impl MimeMessage {
|
|||||||
if let Some(report) = self.process_report(context, mail)? {
|
if let Some(report) = self.process_report(context, mail)? {
|
||||||
self.reports.push(report);
|
self.reports.push(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add MDN part so we can track it, avoid
|
||||||
|
// downloading the message again and
|
||||||
|
// delete if automatic message deletion is
|
||||||
|
// enabled.
|
||||||
|
let mut part = Part::default();
|
||||||
|
part.typ = Viewtype::Unknown;
|
||||||
|
self.parts.push(part);
|
||||||
|
|
||||||
|
any_part_added = true;
|
||||||
} else {
|
} else {
|
||||||
/* eg. `report-type=delivery-status`;
|
/* eg. `report-type=delivery-status`;
|
||||||
maybe we should show them as a little error icon */
|
maybe we should show them as a little error icon */
|
||||||
@@ -1344,7 +1354,7 @@ Disposition: manual-action/MDN-sent-automatically; displayed\n\
|
|||||||
Some("Chat: Message opened".to_string())
|
Some("Chat: Message opened".to_string())
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(message.parts.len(), 0);
|
assert_eq!(message.parts.len(), 1);
|
||||||
assert_eq!(message.reports.len(), 1);
|
assert_eq!(message.reports.len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1422,7 +1432,7 @@ Disposition: manual-action/MDN-sent-automatically; displayed\n\
|
|||||||
Some("Chat: Message opened".to_string())
|
Some("Chat: Message opened".to_string())
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(message.parts.len(), 0);
|
assert_eq!(message.parts.len(), 2);
|
||||||
assert_eq!(message.reports.len(), 2);
|
assert_eq!(message.reports.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1467,7 +1477,7 @@ Additional-Message-IDs: <foo@example.com> <foo@example.net>\n\
|
|||||||
Some("Chat: Message opened".to_string())
|
Some("Chat: Message opened".to_string())
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(message.parts.len(), 0);
|
assert_eq!(message.parts.len(), 1);
|
||||||
assert_eq!(message.reports.len(), 1);
|
assert_eq!(message.reports.len(), 1);
|
||||||
assert_eq!(message.reports[0].original_message_id, "foo@example.org");
|
assert_eq!(message.reports[0].original_message_id, "foo@example.org");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
Reference in New Issue
Block a user