mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +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);
|
cleanup(context, &create_event_to_send, created_db_entries);
|
||||||
|
|
||||||
mime_parser
|
mime_parser
|
||||||
.handle_reports(context, from_id, sent_timestamp)
|
.handle_reports(context, from_id, sent_timestamp, &mime_parser.parts)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -2367,9 +2367,22 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let msg = Message::load_from_db(&t.ctx, msg_id).await.unwrap();
|
||||||
|
assert_eq!(msg.state, MessageState::OutFailed);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Message::load_from_db(&t.ctx, msg_id).await.unwrap().state,
|
msg.param.get(Param::Error),
|
||||||
MessageState::OutFailed
|
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,
|
context: &Context,
|
||||||
from_id: u32,
|
from_id: u32,
|
||||||
rfc724_mid: &str,
|
rfc724_mid: &str,
|
||||||
error: impl AsRef<str>,
|
error: Option<impl AsRef<str>>,
|
||||||
) {
|
) {
|
||||||
if from_id <= DC_MSG_ID_LAST_SPECIAL || rfc724_mid.is_empty() {
|
if from_id <= DC_MSG_ID_LAST_SPECIAL || rfc724_mid.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
match rfc724_mid_exists(context, rfc724_mid).await {
|
let res = context
|
||||||
Ok(Some((_, _, msg_id))) => {
|
.sql
|
||||||
set_msg_failed(context, msg_id, Some(error)).await;
|
.query_row(
|
||||||
}
|
concat!(
|
||||||
Ok(None) => info!(
|
"SELECT",
|
||||||
context,
|
" m.id AS msg_id,",
|
||||||
"Failed to select NDN, could not find failed msg {}", rfc724_mid
|
" 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",
|
||||||
),
|
),
|
||||||
Err(e) => info!(context, "Failed to select NDN {:?}", e),
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -572,7 +572,6 @@ impl MimeMessage {
|
|||||||
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.failed_msg = Some(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut part = Part::default();
|
let mut part = Part::default();
|
||||||
part.typ = Viewtype::Unknown;
|
part.typ = Viewtype::Unknown;
|
||||||
self.parts.push(part);
|
self.parts.push(part);
|
||||||
@@ -854,7 +853,13 @@ impl MimeMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handle reports (only MDNs for now)
|
/// 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 report in &self.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)
|
||||||
@@ -869,7 +874,12 @@ impl MimeMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(original_message_id) = &self.failed_msg {
|
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"))]
|
#[strum(props(fallback = "Message from %1$s"))]
|
||||||
SubjectForNewContact = 73,
|
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