mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 18:06:35 +03:00
Try to add decent error msg (doesnt work yet)
This commit is contained in:
@@ -238,7 +238,7 @@ pub async fn dc_receive_imf(
|
||||
cleanup(context, &create_event_to_send, created_db_entries);
|
||||
|
||||
mime_parser
|
||||
.handle_reports(context, from_id, sent_timestamp)
|
||||
.handle_reports(context, from_id, sent_timestamp, &mime_parser.parts)
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
@@ -2367,9 +2367,22 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let msg = Message::load_from_db(&t.ctx, msg_id).await.unwrap();
|
||||
assert_eq!(msg.state, MessageState::OutFailed);
|
||||
assert_eq!(
|
||||
Message::load_from_db(&t.ctx, msg_id).await.unwrap().state,
|
||||
MessageState::OutFailed
|
||||
);
|
||||
msg.param.get(Param::Error),
|
||||
Some(
|
||||
r"** Die Adresse wurde nicht gefunden **
|
||||
|
||||
Ihre Nachricht wurde nicht an assidhfaaspocwaeofi@gmail.com zugestellt, weil die Adresse nicht gefunden wurde oder keine E-Mails empfangen kann.
|
||||
|
||||
Hier erfahren Sie mehr: https://support.google.com/mail/?p=NoSuchUser
|
||||
|
||||
Antwort:
|
||||
|
||||
550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces. Learn more at https://support.google.com/mail/?p=NoSuchUser i18sor6261697wrs.38 - gsmtp
|
||||
"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1388,21 +1388,56 @@ pub async fn ndn_from_ext(
|
||||
context: &Context,
|
||||
from_id: u32,
|
||||
rfc724_mid: &str,
|
||||
error: impl AsRef<str>,
|
||||
error: Option<impl AsRef<str>>,
|
||||
) {
|
||||
if from_id <= DC_MSG_ID_LAST_SPECIAL || rfc724_mid.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
match rfc724_mid_exists(context, rfc724_mid).await {
|
||||
Ok(Some((_, _, msg_id))) => {
|
||||
set_msg_failed(context, msg_id, Some(error)).await;
|
||||
let res = context
|
||||
.sql
|
||||
.query_row(
|
||||
concat!(
|
||||
"SELECT",
|
||||
" m.id AS msg_id,",
|
||||
" c.id AS chat_id,",
|
||||
" c.type AS type,",
|
||||
" m.to_id AS to_id",
|
||||
" FROM msgs m LEFT JOIN chats c ON m.chat_id=c.id",
|
||||
" WHERE rfc724_mid=? AND from_id=1",
|
||||
),
|
||||
paramsv![rfc724_mid],
|
||||
|row| {
|
||||
Ok((
|
||||
row.get::<_, MsgId>("msg_id")?,
|
||||
row.get::<_, ChatId>("chat_id")?,
|
||||
row.get::<_, Chattype>("type")?,
|
||||
row.get::<_, u32>("to_id")?,
|
||||
))
|
||||
},
|
||||
)
|
||||
.await;
|
||||
if let Err(ref err) = res {
|
||||
info!(context, "Failed to select NDN {:?}", err);
|
||||
}
|
||||
|
||||
if let Ok((msg_id, chat_id, chat_type, contact_id)) = res {
|
||||
set_msg_failed(context, msg_id, error).await;
|
||||
|
||||
if chat_type == Chattype::Group || chat_type == Chattype::VerifiedGroup {
|
||||
let contact = Contact::load_from_db(context, contact_id).await.unwrap();
|
||||
chat::add_info_msg(
|
||||
context,
|
||||
chat_id,
|
||||
context
|
||||
.stock_string_repl_str(
|
||||
StockMessage::FailedSendingTo,
|
||||
contact.get_display_name(),
|
||||
)
|
||||
.await,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
Ok(None) => info!(
|
||||
context,
|
||||
"Failed to select NDN, could not find failed msg {}", rfc724_mid
|
||||
),
|
||||
Err(e) => info!(context, "Failed to select NDN {:?}", e),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -572,7 +572,6 @@ impl MimeMessage {
|
||||
if let Some(report) = self.process_delivery_status(context, mail)? {
|
||||
self.failed_msg = Some(report);
|
||||
}
|
||||
|
||||
let mut part = Part::default();
|
||||
part.typ = Viewtype::Unknown;
|
||||
self.parts.push(part);
|
||||
@@ -854,7 +853,13 @@ impl MimeMessage {
|
||||
}
|
||||
|
||||
/// Handle reports (only MDNs for now)
|
||||
pub async fn handle_reports(&self, context: &Context, from_id: u32, sent_timestamp: i64) {
|
||||
pub async fn handle_reports(
|
||||
&self,
|
||||
context: &Context,
|
||||
from_id: u32,
|
||||
sent_timestamp: i64,
|
||||
parts: &Vec<Part>,
|
||||
) {
|
||||
for report in &self.reports {
|
||||
for original_message_id in
|
||||
std::iter::once(&report.original_message_id).chain(&report.additional_message_ids)
|
||||
@@ -869,7 +874,12 @@ impl MimeMessage {
|
||||
}
|
||||
|
||||
if let Some(original_message_id) = &self.failed_msg {
|
||||
message::ndn_from_ext(context, from_id, original_message_id, "TODO error message").await
|
||||
let error = parts
|
||||
.iter()
|
||||
.find(|p| p.typ == Viewtype::Text)
|
||||
.map(|p| &p.msg);
|
||||
info!(context, "msg_failed {:?}", error);
|
||||
message::ndn_from_ext(context, from_id, original_message_id, error).await
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,9 @@ pub enum StockMessage {
|
||||
|
||||
#[strum(props(fallback = "Message from %1$s"))]
|
||||
SubjectForNewContact = 73,
|
||||
|
||||
#[strum(props(fallback = "Failed to send message to %1$s. See 'info' for more details."))]
|
||||
FailedSendingTo = 74,
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user