mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 14:56:33 +03:00
Improve errors
This commit is contained in:
@@ -1464,7 +1464,7 @@ pub async fn send_msg(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg.param.remove(Param::PrepForwards);
|
msg.param.remove(Param::PrepForwards);
|
||||||
msg.save_param_to_disk(context).await;
|
msg.update_param(context).await;
|
||||||
}
|
}
|
||||||
return send_msg_inner(context, chat_id, msg).await;
|
return send_msg_inner(context, chat_id, msg).await;
|
||||||
}
|
}
|
||||||
@@ -2596,7 +2596,7 @@ pub async fn forward_msgs(
|
|||||||
.set(Param::PrepForwards, new_msg_id.to_u32().to_string());
|
.set(Param::PrepForwards, new_msg_id.to_u32().to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.save_param_to_disk(context).await;
|
msg.update_param(context).await;
|
||||||
msg.param = save_param;
|
msg.param = save_param;
|
||||||
} else {
|
} else {
|
||||||
msg.state = MessageState::OutPending;
|
msg.state = MessageState::OutPending;
|
||||||
|
|||||||
@@ -2327,6 +2327,8 @@ mod tests {
|
|||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
async fn test_parse_ndn() {
|
async fn test_parse_ndn() {
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
let t = dummy_context().await;
|
let t = dummy_context().await;
|
||||||
t.ctx
|
t.ctx
|
||||||
.set_config(Config::Addr, Some("alice@example.org"))
|
.set_config(Config::Addr, Some("alice@example.org"))
|
||||||
@@ -2367,7 +2369,10 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
println!("Loading msg {}…", msg_id);
|
||||||
let msg = Message::load_from_db(&t.ctx, msg_id).await.unwrap();
|
let msg = Message::load_from_db(&t.ctx, msg_id).await.unwrap();
|
||||||
|
std::io::stdout().flush().unwrap();
|
||||||
|
|
||||||
assert_eq!(msg.state, MessageState::OutFailed);
|
assert_eq!(msg.state, MessageState::OutFailed);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
msg.param.get(Param::Error),
|
msg.param.get(Param::Error),
|
||||||
|
|||||||
@@ -806,7 +806,7 @@ pub async fn send_msg_job(context: &Context, msg_id: MsgId) -> Result<Option<Job
|
|||||||
|
|
||||||
if rendered_msg.is_encrypted && !needs_encryption {
|
if rendered_msg.is_encrypted && !needs_encryption {
|
||||||
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
||||||
msg.save_param_to_disk(context).await;
|
msg.update_param(context).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure!(!recipients.is_empty(), "no recipients for smtp job set");
|
ensure!(!recipients.is_empty(), "no recipients for smtp job set");
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ impl Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !self.id.is_unset() {
|
if !self.id.is_unset() {
|
||||||
self.save_param_to_disk(context).await;
|
self.update_param(context).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -643,10 +643,10 @@ impl Message {
|
|||||||
if duration > 0 {
|
if duration > 0 {
|
||||||
self.param.set_int(Param::Duration, duration);
|
self.param.set_int(Param::Duration, duration);
|
||||||
}
|
}
|
||||||
self.save_param_to_disk(context).await;
|
self.update_param(context).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn save_param_to_disk(&mut self, context: &Context) -> bool {
|
pub async fn update_param(&mut self, context: &Context) -> bool {
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
@@ -1256,7 +1256,7 @@ pub async fn set_msg_failed(context: &Context, msg_id: MsgId, error: Option<impl
|
|||||||
}
|
}
|
||||||
if let Some(error) = error {
|
if let Some(error) = error {
|
||||||
msg.param.set(Param::Error, error.as_ref());
|
msg.param.set(Param::Error, error.as_ref());
|
||||||
warn!(context, "Message failed: {}", error.as_ref());
|
warn!(context, "{} failed: {}", msg_id, error.as_ref());
|
||||||
}
|
}
|
||||||
|
|
||||||
if context
|
if context
|
||||||
|
|||||||
@@ -572,11 +572,14 @@ 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();
|
|
||||||
part.typ = Viewtype::Unknown;
|
|
||||||
self.parts.push(part);
|
|
||||||
|
|
||||||
any_part_added = true;
|
// Add all parts (in fact, AddSinglePartIfKnown() later check if
|
||||||
|
// the parts are really supported)
|
||||||
|
for cur_data in mail.subparts.iter() {
|
||||||
|
if self.parse_mime_recursive(context, cur_data).await? {
|
||||||
|
any_part_added = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
if let Some(first) = mail.subparts.iter().next() {
|
if let Some(first) = mail.subparts.iter().next() {
|
||||||
@@ -878,7 +881,6 @@ impl MimeMessage {
|
|||||||
.iter()
|
.iter()
|
||||||
.find(|p| p.typ == Viewtype::Text)
|
.find(|p| p.typ == Viewtype::Text)
|
||||||
.map(|p| &p.msg);
|
.map(|p| &p.msg);
|
||||||
info!(context, "msg_failed {:?}", error);
|
|
||||||
message::ndn_from_ext(context, from_id, original_message_id, error).await
|
message::ndn_from_ext(context, from_id, original_message_id, error).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user