mirror of
https://github.com/chatmail/core.git
synced 2026-05-01 20:36:31 +03:00
Store contact ID in SendMdn job foreign_id
This change makes it possible to find all pending MDNs for the contact with an SQL query.
This commit is contained in:
25
src/job.rs
25
src/job.rs
@@ -261,7 +261,15 @@ impl Job {
|
|||||||
return Status::Finished(Err(format_err!("MDNs are disabled")));
|
return Status::Finished(Err(format_err!("MDNs are disabled")));
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg_id = MsgId::new(self.foreign_id);
|
let msg_id = if let Some(msg_id) = self.param.get_msg_id() {
|
||||||
|
msg_id
|
||||||
|
} else {
|
||||||
|
return Status::Finished(Err(format_err!(
|
||||||
|
"SendMdn job has invalid parameters: {}",
|
||||||
|
self.param
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
|
||||||
let msg = job_try!(Message::load_from_db(context, msg_id));
|
let msg = job_try!(Message::load_from_db(context, msg_id));
|
||||||
let mimefactory = job_try!(MimeFactory::from_mdn(context, &msg));
|
let mimefactory = job_try!(MimeFactory::from_mdn(context, &msg));
|
||||||
let rendered_msg = job_try!(mimefactory.render());
|
let rendered_msg = job_try!(mimefactory.render());
|
||||||
@@ -422,7 +430,7 @@ impl Job {
|
|||||||
if msg.param.get_bool(Param::WantsMdn).unwrap_or_default()
|
if msg.param.get_bool(Param::WantsMdn).unwrap_or_default()
|
||||||
&& context.get_config_bool(Config::MdnsEnabled)
|
&& context.get_config_bool(Config::MdnsEnabled)
|
||||||
{
|
{
|
||||||
if let Err(err) = send_mdn(context, msg.id) {
|
if let Err(err) = send_mdn(context, &msg) {
|
||||||
warn!(context, "could not send out mdn for {}: {}", msg.id, err);
|
warn!(context, "could not send out mdn for {}: {}", msg.id, err);
|
||||||
return Status::Finished(Err(err));
|
return Status::Finished(Err(err));
|
||||||
}
|
}
|
||||||
@@ -1003,14 +1011,11 @@ fn suspend_smtp_thread(context: &Context, suspend: bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_mdn(context: &Context, msg_id: MsgId) -> Result<()> {
|
fn send_mdn(context: &Context, msg: &Message) -> Result<()> {
|
||||||
job_add(
|
let mut param = Params::new();
|
||||||
context,
|
param.set(Param::MessageId, msg.id.to_u32().to_string());
|
||||||
Action::SendMdn,
|
|
||||||
msg_id.to_u32() as i32,
|
job_add(context, Action::SendMdn, msg.from_id as i32, param, 0);
|
||||||
Params::new(),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/param.rs
10
src/param.rs
@@ -8,6 +8,7 @@ use num_traits::FromPrimitive;
|
|||||||
use crate::blob::{BlobError, BlobObject};
|
use crate::blob::{BlobError, BlobObject};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::error;
|
use crate::error;
|
||||||
|
use crate::message::MsgId;
|
||||||
use crate::mimeparser::SystemMessage;
|
use crate::mimeparser::SystemMessage;
|
||||||
|
|
||||||
/// Available param keys.
|
/// Available param keys.
|
||||||
@@ -116,6 +117,9 @@ pub enum Param {
|
|||||||
|
|
||||||
/// For QR
|
/// For QR
|
||||||
GroupName = b'g',
|
GroupName = b'g',
|
||||||
|
|
||||||
|
/// For MDN-sending job
|
||||||
|
MessageId = b'I',
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Possible values for `Param::ForcePlaintext`.
|
/// Possible values for `Param::ForcePlaintext`.
|
||||||
@@ -312,6 +316,12 @@ impl Params {
|
|||||||
Ok(Some(path))
|
Ok(Some(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_msg_id(&self) -> Option<MsgId> {
|
||||||
|
self.get(Param::MessageId)
|
||||||
|
.and_then(|x| x.parse::<u32>().ok())
|
||||||
|
.map(MsgId::new)
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the given paramter to the passed in `i32`.
|
/// Set the given paramter to the passed in `i32`.
|
||||||
pub fn set_int(&mut self, key: Param, value: i32) -> &mut Self {
|
pub fn set_int(&mut self, key: Param, value: i32) -> &mut Self {
|
||||||
self.set(key, format!("{}", value));
|
self.set(key, format!("{}", value));
|
||||||
|
|||||||
Reference in New Issue
Block a user