mirror of
https://github.com/chatmail/core.git
synced 2026-10-02 03:00:40 +03:00
feat: queue messages for SMTP before encryption
Headers like From and Autocrypt are now added late, right before sending the message over SMTP. This way we advertise the latest list of transports and use the correct From address in the encrypted part even for messages queued while being offline. BCC-self recipients are also added late. For unencrypted messages we only want to send a copy to the sending address, but we don't know the sending address when queueing the message. Adding bcc-self recipients when dequeuing the message also makes it possible to send copies to updated list of relays.
This commit is contained in:
@@ -15,7 +15,9 @@ use crate::headerdef::HeaderDefMap as _;
|
||||
use crate::imap::prefetch_should_download;
|
||||
use crate::imex::{ImexMode, imex};
|
||||
use crate::key;
|
||||
use crate::mimefactory;
|
||||
use crate::securejoin::get_securejoin_qr;
|
||||
use crate::smtp;
|
||||
use crate::test_utils;
|
||||
use crate::test_utils::{
|
||||
TestContext, TestContextManager, alice_keypair, get_chat_msg, mark_as_verified,
|
||||
@@ -5847,15 +5849,32 @@ async fn test_mark_message_as_delivered_only_after_sent_out_fully() -> Result<()
|
||||
/// This simulates the case that a message is successfully sent out,
|
||||
/// but the 'OK' answer from the server doesn't arrive,
|
||||
/// so that the SMTP row stays in the database.
|
||||
pub(crate) async fn first_row_in_smtp_queue(alice: &TestContext) -> (MsgId, String) {
|
||||
alice
|
||||
pub(crate) async fn first_row_in_smtp_queue(context: &TestContext) -> (MsgId, String) {
|
||||
let (rowid, msg_id) = context
|
||||
.sql
|
||||
.query_row_optional("SELECT msg_id, mime FROM smtp ORDER BY id", (), |row| {
|
||||
let msg_id: MsgId = row.get(0)?;
|
||||
let mime: String = row.get(1)?;
|
||||
Ok((msg_id, mime))
|
||||
})
|
||||
.query_row_optional(
|
||||
"SELECT id, msg_id FROM smtp2 ORDER BY id LIMIT 1",
|
||||
(),
|
||||
|row| {
|
||||
let rowid: i64 = row.get(0)?;
|
||||
let msg_id: MsgId = row.get(1)?;
|
||||
Ok((rowid, msg_id))
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("query_row_optional failed")
|
||||
.expect("No SMTP row found")
|
||||
.expect("No SMTP row found");
|
||||
let query_only = true;
|
||||
let queued_mail = context
|
||||
.sql
|
||||
.transaction_ext(query_only, |transaction| {
|
||||
smtp::load_queued_mail(transaction, rowid)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let rendered_mail = mimefactory::render_queued_mail_with_context(queued_mail, context)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
(msg_id, rendered_mail.message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user