mirror of
https://github.com/chatmail/core.git
synced 2026-05-21 07:46:31 +03:00
rename reports
This commit is contained in:
@@ -407,7 +407,7 @@ async fn add_parts(
|
|||||||
|
|
||||||
if chat_id.is_unset() {
|
if chat_id.is_unset() {
|
||||||
// check if the message belongs to an NDN
|
// check if the message belongs to an NDN
|
||||||
if mime_parser.failed_msg.is_some() {
|
if mime_parser.failure_report.is_some() {
|
||||||
*chat_id = ChatId::new(DC_CHAT_ID_TRASH);
|
*chat_id = ChatId::new(DC_CHAT_ID_TRASH);
|
||||||
info!(
|
info!(
|
||||||
context,
|
context,
|
||||||
@@ -648,7 +648,7 @@ async fn add_parts(
|
|||||||
let sent_timestamp = *sent_timestamp;
|
let sent_timestamp = *sent_timestamp;
|
||||||
let is_hidden = *hidden;
|
let is_hidden = *hidden;
|
||||||
let chat_id = *chat_id;
|
let chat_id = *chat_id;
|
||||||
let is_mdn = !mime_parser.reports.is_empty();
|
let is_mdn = !mime_parser.mdn_reports.is_empty();
|
||||||
|
|
||||||
// TODO: can this clone be avoided?
|
// TODO: can this clone be avoided?
|
||||||
let rfc724_mid = rfc724_mid.to_string();
|
let rfc724_mid = rfc724_mid.to_string();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::error::{ensure, Error};
|
|||||||
use crate::events::Event;
|
use crate::events::Event;
|
||||||
use crate::job::{self, Action};
|
use crate::job::{self, Action};
|
||||||
use crate::lot::{Lot, LotState, Meaning};
|
use crate::lot::{Lot, LotState, Meaning};
|
||||||
use crate::mimeparser::{FailedMsg, SystemMessage};
|
use crate::mimeparser::{FailureReport, SystemMessage};
|
||||||
use crate::param::*;
|
use crate::param::*;
|
||||||
use crate::pgp::*;
|
use crate::pgp::*;
|
||||||
use crate::stock::StockMessage;
|
use crate::stock::StockMessage;
|
||||||
@@ -1398,7 +1398,7 @@ pub async fn mdn_from_ext(
|
|||||||
/// Where appropriate, also adds an info message telling the user which of the recipients of a group message failed.
|
/// Where appropriate, also adds an info message telling the user which of the recipients of a group message failed.
|
||||||
pub(crate) async fn ndn_from_ext(
|
pub(crate) async fn ndn_from_ext(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
failed: &FailedMsg,
|
failed: &FailureReport,
|
||||||
error: Option<impl AsRef<str>>,
|
error: Option<impl AsRef<str>>,
|
||||||
) {
|
) {
|
||||||
if failed.rfc724_mid.is_empty() {
|
if failed.rfc724_mid.is_empty() {
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ pub struct MimeMessage {
|
|||||||
pub message_kml: Option<location::Kml>,
|
pub message_kml: Option<location::Kml>,
|
||||||
pub(crate) user_avatar: Option<AvatarAction>,
|
pub(crate) user_avatar: Option<AvatarAction>,
|
||||||
pub(crate) group_avatar: Option<AvatarAction>,
|
pub(crate) group_avatar: Option<AvatarAction>,
|
||||||
pub(crate) reports: Vec<Report>,
|
pub(crate) mdn_reports: Vec<Report>,
|
||||||
pub(crate) failed_msg: Option<FailedMsg>,
|
pub(crate) failure_report: Option<FailureReport>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
@@ -178,13 +178,13 @@ impl MimeMessage {
|
|||||||
signatures,
|
signatures,
|
||||||
gossipped_addr,
|
gossipped_addr,
|
||||||
is_forwarded: false,
|
is_forwarded: false,
|
||||||
reports: Vec::new(),
|
mdn_reports: Vec::new(),
|
||||||
is_system_message: SystemMessage::Unknown,
|
is_system_message: SystemMessage::Unknown,
|
||||||
location_kml: None,
|
location_kml: None,
|
||||||
message_kml: None,
|
message_kml: None,
|
||||||
user_avatar: None,
|
user_avatar: None,
|
||||||
group_avatar: None,
|
group_avatar: None,
|
||||||
failed_msg: None,
|
failure_report: None,
|
||||||
};
|
};
|
||||||
parser.parse_mime_recursive(context, &mail).await?;
|
parser.parse_mime_recursive(context, &mail).await?;
|
||||||
parser.heuristically_parse_ndn().await;
|
parser.heuristically_parse_ndn().await;
|
||||||
@@ -357,7 +357,7 @@ impl MimeMessage {
|
|||||||
// just have send a message in the subject with an empty body.
|
// just have send a message in the subject with an empty body.
|
||||||
// Besides, we want to show something in case our incoming-processing
|
// Besides, we want to show something in case our incoming-processing
|
||||||
// failed to properly handle an incoming message.
|
// failed to properly handle an incoming message.
|
||||||
if self.parts.is_empty() && self.reports.is_empty() {
|
if self.parts.is_empty() && self.mdn_reports.is_empty() {
|
||||||
let mut part = Part::default();
|
let mut part = Part::default();
|
||||||
part.typ = Viewtype::Text;
|
part.typ = Viewtype::Text;
|
||||||
|
|
||||||
@@ -557,7 +557,7 @@ impl MimeMessage {
|
|||||||
match mail.ctype.params.get("report-type").map(|s| s as &str) {
|
match mail.ctype.params.get("report-type").map(|s| s as &str) {
|
||||||
Some("disposition-notification") => {
|
Some("disposition-notification") => {
|
||||||
if let Some(report) = self.process_report(context, mail)? {
|
if let Some(report) = self.process_report(context, mail)? {
|
||||||
self.reports.push(report);
|
self.mdn_reports.push(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add MDN part so we can track it, avoid
|
// Add MDN part so we can track it, avoid
|
||||||
@@ -572,7 +572,7 @@ impl MimeMessage {
|
|||||||
}
|
}
|
||||||
Some("delivery-status") => {
|
Some("delivery-status") => {
|
||||||
if let Some(report) = self.process_delivery_status(context, mail)? {
|
if let Some(report) = self.process_delivery_status(context, mail)? {
|
||||||
self.failed_msg = Some(report);
|
self.failure_report = Some(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all parts (in fact, AddSinglePartIfKnown() later check if
|
// Add all parts (in fact, AddSinglePartIfKnown() later check if
|
||||||
@@ -861,7 +861,7 @@ impl MimeMessage {
|
|||||||
&self,
|
&self,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
report: &mailparse::ParsedMail<'_>,
|
report: &mailparse::ParsedMail<'_>,
|
||||||
) -> Result<Option<FailedMsg>> {
|
) -> Result<Option<FailureReport>> {
|
||||||
// parse as mailheaders
|
// parse as mailheaders
|
||||||
if let Some(original_msg) = report
|
if let Some(original_msg) = report
|
||||||
.subparts
|
.subparts
|
||||||
@@ -884,7 +884,7 @@ impl MimeMessage {
|
|||||||
None // We do not know which recipient failed
|
None // We do not know which recipient failed
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ok(Some(FailedMsg {
|
return Ok(Some(FailureReport {
|
||||||
rfc724_mid: original_message_id,
|
rfc724_mid: original_message_id,
|
||||||
failed_recipient: to.map(|s| s.addr),
|
failed_recipient: to.map(|s| s.addr),
|
||||||
}));
|
}));
|
||||||
@@ -909,7 +909,7 @@ impl MimeMessage {
|
|||||||
.get(HeaderDef::From_)?
|
.get(HeaderDef::From_)?
|
||||||
.to_ascii_lowercase()
|
.to_ascii_lowercase()
|
||||||
.contains("daemon")
|
.contains("daemon")
|
||||||
&& self.failed_msg.is_none()
|
&& self.failure_report.is_none()
|
||||||
{
|
{
|
||||||
for line in self
|
for line in self
|
||||||
.parts
|
.parts
|
||||||
@@ -922,7 +922,7 @@ impl MimeMessage {
|
|||||||
}
|
}
|
||||||
if let Some(c) = RE.captures(line) {
|
if let Some(c) = RE.captures(line) {
|
||||||
if let Ok(original_message_id) = parse_message_id(&c[1]) {
|
if let Ok(original_message_id) = parse_message_id(&c[1]) {
|
||||||
self.failed_msg = Some(FailedMsg {
|
self.failure_report = Some(FailureReport {
|
||||||
rfc724_mid: original_message_id,
|
rfc724_mid: original_message_id,
|
||||||
failed_recipient: None,
|
failed_recipient: None,
|
||||||
})
|
})
|
||||||
@@ -943,7 +943,7 @@ impl MimeMessage {
|
|||||||
sent_timestamp: i64,
|
sent_timestamp: i64,
|
||||||
parts: &[Part],
|
parts: &[Part],
|
||||||
) {
|
) {
|
||||||
for report in &self.reports {
|
for report in &self.mdn_reports {
|
||||||
for original_message_id in
|
for original_message_id in
|
||||||
std::iter::once(&report.original_message_id).chain(&report.additional_message_ids)
|
std::iter::once(&report.original_message_id).chain(&report.additional_message_ids)
|
||||||
{
|
{
|
||||||
@@ -956,7 +956,7 @@ impl MimeMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(original_message_id) = &self.failed_msg {
|
if let Some(original_message_id) = &self.failure_report {
|
||||||
let error = parts.iter().find(|p| p.typ == Viewtype::Text).map(|p| {
|
let error = parts.iter().find(|p| p.typ == Viewtype::Text).map(|p| {
|
||||||
let msg = &p.msg;
|
let msg = &p.msg;
|
||||||
match msg.find("\n--- ") {
|
match msg.find("\n--- ") {
|
||||||
@@ -1024,7 +1024,7 @@ pub(crate) struct Report {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct FailedMsg {
|
pub(crate) struct FailureReport {
|
||||||
pub rfc724_mid: String,
|
pub rfc724_mid: String,
|
||||||
pub failed_recipient: Option<String>,
|
pub failed_recipient: Option<String>,
|
||||||
}
|
}
|
||||||
@@ -1519,7 +1519,7 @@ Disposition: manual-action/MDN-sent-automatically; displayed\n\
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(message.parts.len(), 1);
|
assert_eq!(message.parts.len(), 1);
|
||||||
assert_eq!(message.reports.len(), 1);
|
assert_eq!(message.mdn_reports.len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test parsing multiple MDNs combined in a single message.
|
/// Test parsing multiple MDNs combined in a single message.
|
||||||
@@ -1599,7 +1599,7 @@ Disposition: manual-action/MDN-sent-automatically; displayed\n\
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(message.parts.len(), 2);
|
assert_eq!(message.parts.len(), 2);
|
||||||
assert_eq!(message.reports.len(), 2);
|
assert_eq!(message.mdn_reports.len(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
@@ -1646,10 +1646,13 @@ Additional-Message-IDs: <foo@example.com> <foo@example.net>\n\
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(message.parts.len(), 1);
|
assert_eq!(message.parts.len(), 1);
|
||||||
assert_eq!(message.reports.len(), 1);
|
assert_eq!(message.mdn_reports.len(), 1);
|
||||||
assert_eq!(message.reports[0].original_message_id, "foo@example.org");
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&message.reports[0].additional_message_ids,
|
message.mdn_reports[0].original_message_id,
|
||||||
|
"foo@example.org"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
&message.mdn_reports[0].additional_message_ids,
|
||||||
&["foo@example.com", "foo@example.net"]
|
&["foo@example.com", "foo@example.net"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user