Move foreign_id handling out of mimefactory

This commit is contained in:
Alexander Krotov
2020-01-16 23:10:32 +03:00
parent a806728e43
commit 3cd0bbc0f4
2 changed files with 8 additions and 21 deletions

View File

@@ -785,7 +785,7 @@ pub fn job_send_msg(context: &Context, msg_id: MsgId) -> Result<()> {
msg.save_param_to_disk(context);
}
add_smtp_job(context, Action::SendMsgToSmtp, &rendered_msg)?;
add_smtp_job(context, Action::SendMsgToSmtp, msg.id, &rendered_msg)?;
Ok(())
}
@@ -1010,7 +1010,12 @@ fn send_mdn(context: &Context, msg_id: MsgId) -> Result<()> {
Ok(())
}
fn add_smtp_job(context: &Context, action: Action, rendered_msg: &RenderedEmail) -> Result<()> {
fn add_smtp_job(
context: &Context,
action: Action,
msg_id: MsgId,
rendered_msg: &RenderedEmail,
) -> Result<()> {
ensure!(
!rendered_msg.recipients.is_empty(),
"no recipients for smtp job set"
@@ -1023,16 +1028,7 @@ fn add_smtp_job(context: &Context, action: Action, rendered_msg: &RenderedEmail)
param.set(Param::File, blob.as_name());
param.set(Param::Recipients, &recipients);
job_add(
context,
action,
rendered_msg
.foreign_id
.map(|v| v.to_u32() as i32)
.unwrap_or_default(),
param,
0,
);
job_add(context, action, msg_id.to_u32() as i32, param, 0);
Ok(())
}

View File

@@ -11,7 +11,6 @@ use crate::dc_tools::*;
use crate::e2ee::*;
use crate::error::Error;
use crate::location;
use crate::message::MsgId;
use crate::message::{self, Message};
use crate::mimeparser::SystemMessage;
use crate::param::*;
@@ -53,8 +52,6 @@ pub struct RenderedEmail {
pub is_encrypted: bool,
pub is_gossiped: bool,
pub last_added_location_id: u32,
/// None for MDN, the message id otherwise
pub foreign_id: Option<MsgId>,
pub from: String,
pub recipients: Vec<String>,
@@ -563,8 +560,6 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
recipients,
from_addr,
last_added_location_id,
msg,
loaded,
..
} = self;
@@ -574,10 +569,6 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
is_encrypted,
is_gossiped,
last_added_location_id,
foreign_id: match loaded {
Loaded::Message { .. } => Some(msg.id),
Loaded::MDN => None,
},
recipients: recipients.into_iter().map(|(_, addr)| addr).collect(),
from: from_addr,
rfc724_mid,