fix: Mark a message as delivered only after it has been fully sent out#8062
fix: Mark a message as delivered only after it has been fully sent out#8062
Conversation
2e0c1e6 to
6aea39d
Compare
This can be tested in Rust, you can pop the pre-message from the SMTP queue and pass it to |
| ) | ||
| .await? | ||
| { | ||
| if !msg_has_pending_smtp_job(context, msg_id).await? { |
There was a problem hiding this comment.
Btw, the whole block can be moved to some MsgId::set_delivered_if_fully_sent(), but maybe not hiding the check inside some function is clearer...
|
I wrote a test, and checked that the test fails on main but passes with this PR, but I'll create a separate PR for the test so that it can be reviewed separately. |
Fix #8042
The problem was that after receiving the bcc_self'ed pre-message in
receive_imf, the logic there only looked for a pendingsmtp-table-entry that matches the rfc724_mid, and if there was none then it thought "Great, apparently the message is fully sent out, we can mark it as delivered!".But with pre-messages, the same message can have two
smtpentries (one for the pre-message and one for the post-message), and the message should only be marked as delivered once both of them are sent out.Now, I changed the logic to look for all entries with the same msg_id. This is actually the same SQL query used in smtp.rs, so, I extracted it into a new function; feel free to suggest a better name for it.
I tested on Android that it now works fine.
I'm not sure about a test - it would probably be possible to write a python test that tries to send a very large message, but it would take multiple minutes to complete depending on the speed of the internet, and it would depend on the server rejecting large messages.
There are a lot of other problems with sending large files, though:
See #8078 for the last four of them.