Skip to content

fix: Mark a message as delivered only after it has been fully sent out#8062

Merged
Hocuri merged 3 commits intomainfrom
hoc/add-checkmark-later
Apr 2, 2026
Merged

fix: Mark a message as delivered only after it has been fully sent out#8062
Hocuri merged 3 commits intomainfrom
hoc/add-checkmark-later

Conversation

@Hocuri
Copy link
Copy Markdown
Collaborator

@Hocuri Hocuri commented Mar 31, 2026

Fix #8042

The problem was that after receiving the bcc_self'ed pre-message in receive_imf, the logic there only looked for a pending smtp-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 smtp entries (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:

  • The pre-message is sent before the post-message, so that for the receiver it looks as if the message arrived, but stays in "downloading..." forever: Do not send pre-message if post-message sending failed #8063
  • There is quite a time delay between clicking on "Send" and the outgoing message appearing in the chat
  • The message shortly gets a letter icon right after it is sent
  • I'm wondering if there is a way to give feedback to the user immediately if the message is too big
  • It's unclear when exactly we want to send read receipts

See #8078 for the last four of them.

@Hocuri Hocuri force-pushed the hoc/add-checkmark-later branch from 2e0c1e6 to 6aea39d Compare March 31, 2026 22:50
@Hocuri Hocuri changed the title [WIP] Try to mark a message as delivered only after it has been fully sent out fix: Mark a message as delivered only after it has been fully sent out Mar 31, 2026
@iequidoo
Copy link
Copy Markdown
Collaborator

iequidoo commented Apr 1, 2026

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.

This can be tested in Rust, you can pop the pre-message from the SMTP queue and pass it to receive_imf. This doesn't block the fix though, if you want, i can do a follow-up PR with a test.

)
.await?
{
if !msg_has_pending_smtp_job(context, msg_id).await? {
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.

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...

@Hocuri Hocuri requested a review from link2xt April 1, 2026 09:04
@Hocuri Hocuri merged commit 626ac81 into main Apr 2, 2026
30 checks passed
@Hocuri Hocuri deleted the hoc/add-checkmark-later branch April 2, 2026 13:12
@Hocuri
Copy link
Copy Markdown
Collaborator Author

Hocuri commented Apr 2, 2026

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.

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.

When sending a very large file, the message gets a checkmark before it is fully sent out

2 participants