mirror of
https://github.com/chatmail/core.git
synced 2026-05-24 09:16:32 +03:00
test: Add function to queue MDN into smtp
This commit is contained in:
35
src/smtp.rs
35
src/smtp.rs
@@ -13,7 +13,7 @@ use crate::config::Config;
|
|||||||
use crate::contact::{Contact, ContactId};
|
use crate::contact::{Contact, ContactId};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::events::EventType;
|
use crate::events::EventType;
|
||||||
use crate::log::{LogExt, warn};
|
use crate::log::warn;
|
||||||
use crate::message::Message;
|
use crate::message::Message;
|
||||||
use crate::message::{self, MsgId};
|
use crate::message::{self, MsgId};
|
||||||
use crate::mimefactory::MimeFactory;
|
use crate::mimefactory::MimeFactory;
|
||||||
@@ -590,6 +590,10 @@ async fn send_mdn_rfc724_mid(
|
|||||||
if context.get_config_bool(Config::BccSelf).await? {
|
if context.get_config_bool(Config::BccSelf).await? {
|
||||||
add_self_recipients(context, &mut recipients, encrypted).await?;
|
add_self_recipients(context, &mut recipients, encrypted).await?;
|
||||||
}
|
}
|
||||||
|
#[cfg(not(test))]
|
||||||
|
{
|
||||||
|
use crate::log::LogExt;
|
||||||
|
|
||||||
let recipients: Vec<_> = recipients
|
let recipients: Vec<_> = recipients
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|addr| {
|
.filter_map(|addr| {
|
||||||
@@ -628,6 +632,35 @@ async fn send_mdn_rfc724_mid(
|
|||||||
}
|
}
|
||||||
SendResult::Failure(err) => Err(err),
|
SendResult::Failure(err) => Err(err),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#[cfg(test)]
|
||||||
|
{
|
||||||
|
let _ = smtp;
|
||||||
|
context
|
||||||
|
.sql
|
||||||
|
.transaction(|t| {
|
||||||
|
t.execute(
|
||||||
|
"INSERT INTO smtp (rfc724_mid, recipients, mime, msg_id)
|
||||||
|
VALUES (?, ?, ?, ?)",
|
||||||
|
(rfc724_mid, recipients.join(" "), body, u32::MAX),
|
||||||
|
)?;
|
||||||
|
let mut stmt = t.prepare("DELETE FROM smtp_mdns WHERE rfc724_mid = ?")?;
|
||||||
|
stmt.execute((rfc724_mid,))?;
|
||||||
|
for additional_rfc724_mid in additional_rfc724_mids {
|
||||||
|
stmt.execute((additional_rfc724_mid,))?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) async fn queue_mdn(context: &Context) -> Result<()> {
|
||||||
|
let queued = send_mdn(context, &mut Smtp::new()).await?;
|
||||||
|
assert!(queued);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tries to send a single MDN. Returns true if more MDNs should be sent.
|
/// Tries to send a single MDN. Returns true if more MDNs should be sent.
|
||||||
|
|||||||
Reference in New Issue
Block a user