Skip to content

refactor(mimefactory): separate rendering of message payload and sendable message - #8345

Open
link2xt wants to merge 1 commit into
mainfrom
link2xt/last_added_location_timestamp
Open

refactor(mimefactory): separate rendering of message payload and sendable message#8345
link2xt wants to merge 1 commit into
mainfrom
link2xt/last_added_location_timestamp

Conversation

@link2xt

@link2xt link2xt commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

This change separates rendering into two separate steps:

  1. Rendering of the message payload without the From, Message-ID and Autocrypt headers.
  2. Adding the From, Message-ID and Autocrypt headers and possibly encrypting the message.

The goal is to have serializable result of the first step
that can be persisted in the database and sent later with any email address.
This way it will be possible to send queued messages over any relay.

This will make it possible not to remove all messages from the queue
when the sending relay is changed.
Currently changing configured_addr deletes everything from smtp table.

This change is however only a refactoring and does not implement any features.


This is a refactoring PR in preparation for automatic relay failover.

As a side effect it also makes possible to change the Date of the message for #8112 if we decide on this approach (unlikely).

Serializable mail is currently called mimefactory::QueuedMail. Everything except the public keys is trivially serializable, public keys should likely be serialized as recipient fingerprints rather than as OpenPGP certificates.

I also noticed that we likely can remove the concept of "hidden headers" which are headers that are sent on the mulipart/mixed level of unencrypted messages. They are used to send Chat-Edit headers and avatars in unencrypted messages. Sending avatars in unencrypted messages is not useful because they are not displayed anyway. And we can decide to make it impossible to edit and delete unencrypted messages. I have not changed anything in this PR, however, hidden headers work as before.

@link2xt link2xt changed the title fix: replace last_added_location_id with last_added_location_timestamp MimeFactory refactoring and fixes Jun 18, 2026
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch 4 times, most recently from 45102bc to 1956c42 Compare June 18, 2026 18:00
@link2xt
link2xt marked this pull request as ready for review June 19, 2026 01:33
@link2xt
link2xt marked this pull request as draft June 19, 2026 01:33
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch 3 times, most recently from 5f3c57c to f9c33de Compare June 20, 2026 01:02
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch from f9c33de to e314fc0 Compare June 20, 2026 04:25
@link2xt
link2xt changed the base branch from main to link2xt/location-streaming-fixes June 20, 2026 04:26
@link2xt
link2xt force-pushed the link2xt/location-streaming-fixes branch from 3d4610c to b1b0e3f Compare June 20, 2026 04:29
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch 2 times, most recently from ce43887 to 6abd90c Compare June 20, 2026 19:48
@link2xt link2xt changed the title MimeFactory refactoring and fixes MimeFactory refactoring Jun 20, 2026
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch from 6abd90c to e350dd6 Compare June 20, 2026 20:01
@link2xt
link2xt changed the base branch from link2xt/location-streaming-fixes to main June 20, 2026 20:02
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch 3 times, most recently from a18ab11 to 2e20218 Compare June 20, 2026 20:38
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch 5 times, most recently from a39da96 to 1c19dd8 Compare June 22, 2026 10:07
@link2xt
link2xt changed the base branch from main to link2xt/location-streaming-fixes June 22, 2026 10:08
Comment thread src/mimefactory.rs
Comment thread src/mimefactory.rs Outdated
@Hocuri

Hocuri commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

I also noticed that we likely can remove the concept of "hidden headers" which are headers that are sent on the mulipart/mixed level of unencrypted messages. They are used to send Chat-Edit headers and avatars in unencrypted messages. Sending avatars in unencrypted messages is not useful because they are not displayed anyway. And we can decide to make it impossible to edit and delete unencrypted messages. I have not changed anything in this PR, however, hidden headers work as before.

Agreed, there is no need to support chat-like features in unencrypted messages anymore. Hidden headers are from a time when we wanted to enable nice DC-to-DC communication via unencrypted messages with avatars etc.

@r10s

r10s commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

ftr, some history: we had late-mime-generation until 2018 and switched to early-mime-generation for various reasons, mainly speed and disappearing-messages, thid old core-c issue shows more detailes deltachat/deltachat-core#427

while performance might still be a concern, esp when there are only short time windows to get things out, iiuc, in this PR most data to be sent out are still generated early, so eg it is fine if database records the message originates from are deleted, this is important eg. for disappearing messages

that time, however, mime-generation included encryption, so doing that late uses the state of the database when message goes out, not the state when send button is pressed, which led to all kind of issues.

if i get it corectly, this is not the case with this PR, the mime

@Hocuri

Hocuri commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

I made some measurements on my 5 year old middle-class phone (Fairphone 3), compiled in release mode.

FTR, this PR here doesn't switch to late encryption yet (it's just refactoring that will enable us to switch to late encryption). And yes, the plan is to switch to late encryption, but keep early mime generation.

Once we switch to late encryption, the function render_queued_mail will be executed before every sending attempt rather than just once. For an image, it took 0.1s - 0.2s, which seems fine. For a 10MB document, it took 3.5s, which is a lot, but also, I'm not sure if there is a realistic alternative, and most of the time users don't send 10MB documents. An advantage of late encryption will probably be that the message already appears in the chat before it's encrypted (we can't test that yet because late encryption is not implemented yet).

Text:
07-10 14:12:03.833 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2843: pre_render took 5.23625ms
07-10 14:12:03.846 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2853: render_queued_mail took 12.344167ms

Image:
07-10 14:12:31.241 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2787: post-message pre_render took 10.24974ms
07-10 14:12:31.442 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2802: post-message render_queued_mail took 202.123281ms
07-10 14:12:31.444 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2814: pre-message pre_render took 1.15401ms
07-10 14:12:31.446 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2824: pre-message render_queued_mail took 2.330677ms

Large image that was recoded: (note that the recoding itself happens before pre_render)
07-10 14:13:01.141 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2787: post-message pre_render took 7.337344ms
07-10 14:13:01.253 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2802: post-message render_queued_mail took 111.358542ms
07-10 14:13:01.254 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2814: pre-message pre_render took 1.570625ms
07-10 14:13:01.257 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2824: pre-message render_queued_mail took 3.268594ms

10MB document:
07-10 14:13:30.648 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2787: post-message pre_render took 162.277239ms
07-10 14:13:34.175 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2802: post-message render_queued_mail took 3.527979478s
07-10 14:13:34.177 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2814: pre-message pre_render took 1.408177ms
07-10 14:13:34.179 15848 15869 I DeltaChat: [accId=1] src/chat.rs:2824: pre-message render_queued_mail took 2.378177ms
Click to see the diff I used for measuring
diff --git a/src/chat.rs b/src/chat.rs
index 0ad2fd49d..9ee6bfc65 100644
--- a/src/chat.rs
+++ b/src/chat.rs
@@ -6,7 +6,7 @@
 use std::io::Cursor;
 use std::marker::Sync;
 use std::path::{Path, PathBuf};
-use std::time::Duration;
+use std::time::{Duration, Instant};
 
 use anyhow::{Context as _, Result, anyhow, bail, ensure};
 use chrono::TimeZone;
@@ -2780,10 +2780,17 @@ async fn render_mime_message_and_pre_message(
 
         let mut mimefactory_post_msg = mimefactory.clone();
         mimefactory_post_msg.set_as_post_message();
+        let start = Instant::now();
         let (queued_msg, side_effects) = Box::pin(mimefactory_post_msg.pre_render(context))
             .await
             .context("Failed to render post-message")?;
+        info!(
+            context,
+            "post-message pre_render took {:?}",
+            start.elapsed()
+        );
 
+        let start = Instant::now();
         let rendered_msg = mimefactory::render_queued_mail(
             queued_msg,
             &public_key,
@@ -2792,12 +2799,20 @@ async fn render_mime_message_and_pre_message(
             timestamp,
             side_effects,
         )?;
+        info!(
+            context,
+            "post-message render_queued_mail took {:?}",
+            start.elapsed()
+        );
 
         let mut mimefactory_pre_msg = mimefactory;
         mimefactory_pre_msg.set_as_pre_message_for(&rendered_msg);
+        let start = Instant::now();
         let (queued_pre_msg, pre_side_effects) = Box::pin(mimefactory_pre_msg.pre_render(context))
             .await
             .context("pre-message failed to render")?;
+        info!(context, "pre-message pre_render took {:?}", start.elapsed());
+        let start = Instant::now();
         let rendered_pre_msg = mimefactory::render_queued_mail(
             queued_pre_msg,
             &public_key,
@@ -2806,6 +2821,11 @@ async fn render_mime_message_and_pre_message(
             timestamp,
             pre_side_effects,
         )?;
+        info!(
+            context,
+            "pre-message render_queued_mail took {:?}",
+            start.elapsed()
+        );
 
         if rendered_pre_msg.message.len() > PRE_MSG_SIZE_WARNING_THRESHOLD {
             warn!(
@@ -2818,7 +2838,10 @@ async fn render_mime_message_and_pre_message(
 
         Ok((Some(rendered_pre_msg), rendered_msg))
     } else {
+        let start = Instant::now();
         let (queued_msg, side_effects) = Box::pin(mimefactory.pre_render(context)).await?;
+        info!(context, "pre_render took {:?}", start.elapsed());
+        let start = Instant::now();
         let rendered_msg = mimefactory::render_queued_mail(
             queued_msg,
             &public_key,
@@ -2827,6 +2850,7 @@ async fn render_mime_message_and_pre_message(
             timestamp,
             side_effects,
         )?;
+        info!(context, "render_queued_mail took {:?}", start.elapsed());
 
         Ok((None, rendered_msg))
     }

@Hocuri Hocuri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review

Comment thread src/mimefactory.rs Outdated
Comment on lines +1258 to +1266
let (queued_mail, side_effects) = Box::pin(self.pre_render(context)).await?;
let rendered_mail = render_queued_mail(
queued_mail,
&public_key,
&secret_key,
from_addr,
timestamp,
side_effects,
)?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

render_queued_mail() is a blocking function (possibly blocking for multiple seconds) that is called without spawn_blocking() or block_in_place() both here and in multiple other places. This needs to be fixed in order not to block the executor

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, spawn_blocking() was removed from pk_encrypt(). I think, to protect from blocking the executor in such cases, we should use block_in_place() at the lower level, i.e. in pk_encrypt() while still calling spawn_blocking() here and in other high-level functions. So, even if spawn_blocking() is forgotten, the worst thing is other futures in the same task getting blocked, not other tasks. Nested block_in_place() should be fine (no-op), see discussion in tokio-rs/tokio#2327

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrapped calls into block_in_place() and added a note to the documentation of render_queued_mail.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to express this using the type system than the documentation that could be missed by function users, i.e. add some artificial token parameter to render_queued_mail() and wrappers for block_in_place() and spawn_blocking() that generate a token that can be passed into the function. At least this way you can grep all places in the code where such tokens are generated and check that blocking is fine there.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved block_in_place() into pk_encrypt().

I don't know how we actually want to handle this, it does not look great to make functions that have nothing to do with async depend on tokio and it is not clear how much CPU usage is considered "blocking". Maybe we should move all block_in_place to lower levels, but then we should also do it for create_keypair, instead of using spawn_blocking in generate_keypair.

Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs
Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs

if is_encrypted {
// Copy not protected headers to outer headers.
let (parsed_headers, _index) = mailparse::parse_headers(&raw_message)?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR, we're first building the message and then parsing it again, but this parse_headers call takes just 5µs-80µs in my measurements (5 year old middle-class phone, release mode), and code-wise it seems like the easiest solution, so, it's good as-is.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...although the only header we actually need is Chat-Is-Post-Message. For all the others (Subject, To, Chat-Version) it's already clear that they should be added and with which value. So, the code here could be slightly simplified by putting pre_message_mode on QueuedMail, and then always mechanically adding these four outer headers. Then we wouldn't need to parse the message here and iterate over all headers.

But it's fine as-is, too

Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs

if is_encrypted {
// Copy not protected headers to outer headers.
let (parsed_headers, _index) = mailparse::parse_headers(&raw_message)?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...although the only header we actually need is Chat-Is-Post-Message. For all the others (Subject, To, Chat-Version) it's already clear that they should be added and with which value. So, the code here could be slightly simplified by putting pre_message_mode on QueuedMail, and then always mechanically adding these four outer headers. Then we wouldn't need to parse the message here and iterate over all headers.

But it's fine as-is, too

Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs
} else {
SeipdVersion::V1
};
let display_name = if is_securejoin_message && !is_encrypted {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, the naming of will_be_encrypted is correct. If the message is symmetrically-encrypted, then encryption_pubkeys is Some(vec![]). As @link2xt said elsewhere, would be a nice refactoring to put this into an enum instead in order to prevent such confusion.

The "vc-pubkey" and "vc-request-pubkey" messages don't use the function here. Instead, they are created by render_symm_encrypted_securejoin_message. This is why the code works as correctly. Thanks for writing a test for it!

Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs
@@ -2022,84 +2293,26 @@ struct HeadersByConfidentiality {
/// See [`HeadersByConfidentiality`] for more info.
fn group_headers_by_confidentiality(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put a comment here that this function isn't really needed anymore and can be removed once we remove hidden headers?

Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs Outdated
Comment thread src/mimefactory.rs
@iequidoo
iequidoo self-requested a review July 12, 2026 14:51
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch from 598ac45 to 72d547a Compare July 16, 2026 14:31
@link2xt

link2xt commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

I made some measurements on my 5 year old middle-class phone (Fairphone 3), compiled in release mode.
For a 10MB document, it took 3.5s

Could you check if removing compression support from pk_encrypt helps?

Asymmetric encryption is constant-time and should not depend on the message size, and symmetric AES encryption is supposed to be cheap and not taking seconds for 10 MB message, so I suspect the slowest part is OpenPGP compression. If it is that slow, it's one more reason to get rid of it.

For encrypted attachments we don't need to worry about compatibility, so can even send them as binary MIME without base64-encoding, this will also reduce memory usage for the receivers and may help iOS. Large attachments are likely don't compress well as videos and images are already compressed, webxdcs are zip archives, and zlib compression cannot compress them further, so even just dropping compression already might be an improvement.

The only reason for OpenPGP compression currently is compensating base64-encoding of binary attachments. Attachments are base64-encoded, then compressed, then signed and encrypted, then the whole encrypted messages is ASCII-armored. Compression negates the first base64-encoding, but we don't have to do it in the first place, mailparse at least theoretically supports binary attachments.

@Hocuri

Hocuri commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Removing compression only helped a little bit, reducing the time from 3.5s to 2.6s. Additionally Ordering Rust to optimize for speed rather than binary size gets it down to 1.6s (I did not check how this affects the APK size).

10MB file (release mode) without compression in `pk_encrypt`:
07-17 15:13:24.309 17503 17532 I DeltaChat: [accId=1] src/chat.rs:2787: post-message into_queued_mail took 164.499219ms
07-17 15:13:26.929 17503 17532 I DeltaChat: [accId=1] src/chat.rs:2802: post-message render_queued_mail took 2.620136926s
07-17 15:13:26.930 17503 17532 I DeltaChat: [accId=1] src/chat.rs:2815: pre-message into_queued_mail took 1.157136ms
07-17 15:13:26.932 17503 17532 I DeltaChat: [accId=1] src/chat.rs:2829: pre-message render_queued_mail took 1.924167ms

10MB file (release mode) without compression, and also I removed `opt-level = "z"` from `Cargo.toml`:
07-17 15:27:14.397 21861 21882 I DeltaChat: [accId=1] src/chat.rs:2787: post-message into_queued_mail took 121.951146ms
07-17 15:27:15.981 21861 21882 I DeltaChat: [accId=1] src/chat.rs:2802: post-message render_queued_mail took 1.583441666s
07-17 15:27:15.981 21861 21882 I DeltaChat: [accId=1] src/chat.rs:2815: pre-message into_queued_mail took 893.177µs
07-17 15:27:15.983 21861 21882 I DeltaChat: [accId=1] src/chat.rs:2829: pre-message render_queued_mail took 1.358073ms

@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch 3 times, most recently from de45e20 to 95aba6d Compare July 23, 2026 22:07
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch 7 times, most recently from af647e7 to 5eb92c2 Compare July 31, 2026 17:45
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch from 5eb92c2 to eef6ea4 Compare August 1, 2026 00:02

@hpk42 hpk42 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this looks good modulo a couple of medium/minor nits. The unencrypted MDN is probably most relevant, and then maybe the missing block_in_place. I am also in favor of merging this PR soon, and run main on some dev devices.

Comment thread src/mimefactory.rs
Comment on lines 1547 to 1555
// Never add outer multipart/mixed wrapper to MDN
// as multipart/report Content-Type is used to recognize MDNs
// by Delta Chat receiver and Chatmail servers
// allowing them to be unencrypted and not contain Autocrypt header
// without resetting Autocrypt encryption or triggering Chatmail filter
// that normally only allows encrypted mails.

// Hidden headers are dropped.
message

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure we want to get rid of unencrypted MDNs completely. Not implemented yet but it's better to just bail out here and drop the complex comment.

Suggested change
// MDNs are only sent encrypted. Unencrypted MDNs are being
// phased out but not fully prevented yet, so just refuse to render them here.
bail!("unencrypted MDNs are not sent");
}

Comment thread src/pgp.rs
Comment on lines 251 to 254
/// Symmetrically encrypt the message.
/// This is used for broadcast channels and for version 2 of the Securejoin protocol.
/// `shared secret` is the secret that will be used for symmetric encryption.
pub fn symm_encrypt_message(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this need block_in_place like pk_encrypt?

Comment thread src/chat.rs
msg.chat_id
.set_selfavatar_timestamp(context, now)
.await
.context("Failed to set selfavatar timestamp")?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this changed from just logging an error in the background to aborting create_send_msg_jobs?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that the reason is that if one SQL statement errors, then there is usually not much point in continuing to try using the database (except there is a syntax error in the SQL statement, but then every test touching this code would fail)

Comment thread src/download.rs
Comment thread src/mimefactory.rs
}
unprotected_headers.push(("To", hidden_recipients().into()));
} else if header_name == "chat-broadcast-secret" {
if is_encrypted {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about just dropping this guard. the secret should never go out in unencrypted messages. Maybe some ensure_and_debug_assert!(...no-Chat-Broadcast-Secret..) in the unencrypted path makes sense?

Comment thread src/mimefactory.rs
let date = chrono::DateTime::<chrono::Utc>::from_timestamp(self.timestamp, 0)
.unwrap()
.to_rfc2822();
headers.push(("Date", mail_builder::headers::raw::Raw::new(date).into()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Date now precedes To/Subject? nobody should care, just unusual for old-school readers like me :)

Comment thread src/mimefactory.rs
Comment on lines +1106 to +1117
.iter()
.map(|(name, addr)| {
Address::new_address(
if name.is_empty() {
None
} else {
Some(name.to_string())
},
addr.clone(),
)
})
.collect()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sidenote: i really dislike such waste of vertical lines, as it impedes readability. It's not new code but while i am at it, i think something like self.to.iter().map(to_address).collect() would be preferrable (with an approprirate to_address helper).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, there already is fn new_address_with_name, although can't be used as .map(new_address_with_name) takes (&str, String) rather than (&String, &String)

Comment thread src/chat.rs
msg.chat_id
.set_selfavatar_timestamp(context, now)
.await
.context("Failed to set selfavatar timestamp")?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that the reason is that if one SQL statement errors, then there is usually not much point in continuing to try using the database (except there is a syntax error in the SQL statement, but then every test touching this code would fail)

Comment thread src/imap.rs Outdated
Comment thread src/mimefactory.rs
Comment on lines +1106 to +1117
.iter()
.map(|(name, addr)| {
Address::new_address(
if name.is_empty() {
None
} else {
Some(name.to_string())
},
addr.clone(),
)
})
.collect()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, there already is fn new_address_with_name, although can't be used as .map(new_address_with_name) takes (&str, String) rather than (&String, &String)

@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch from eef6ea4 to cd0eb02 Compare August 3, 2026 13:40
…able message

This change separates rendering into two separate steps:
1. Rendering of the message payload without the From, Date and Autocrypt headers.
2. Adding the From, Date and Autocrypt headers and possibly encrypting the message.

The goal is to have serializable result of the first step
that can be persisted in the database and sent later with any email address.
This way it will be possible to send queued messages over any relay.

This will make it possible not to remove all messages from the queue
when the sending relay is changed.
Currently changing `configured_addr` deletes everything from `smtp` table.

This change is however only a refactoring and does not implement any features.
@link2xt
link2xt force-pushed the link2xt/last_added_location_timestamp branch from cd0eb02 to 6515b30 Compare August 3, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants