Skip to content

Conversation

@Simon-Laux
Copy link
Contributor

@Simon-Laux Simon-Laux commented Nov 12, 2025

This PR implements receiving of pre-message, download of full messages and the new logic for deciding what to fetch when from IMAP.

This is part of #7367


progress:

  • changes to imap loop
  • change download table to work with rfc724_mid instead of msg_id (added db migration for it)
  • add a table for available_full_msgs
  • move download logic from scheduler.rs to download.rs
  • receive_imf
    • implement pre message
    • implement full message (if pre message exists then replace only attachment and change view type)
  • Metadata in pre-message in header as struct (atleast attachment size, so UI can ask for correct size to display on dl button)
  • delete metadata params once message is downloaded
  • re-check logic / self review
  • write tests (recycle old tests that I removed in remove: partial downloads (remove creation of the stub messages) #7373 and write new ones) - progress in feat: receive pre-messages and adapt download on demand #7431 (comment)

specific aspects that should become reality:

  • In receive_imf, the full-message can be handled similarly to Chat-Edit (grep for "ChatEdit" in receive_imf.rs).
  • As opposed to the current download-on-demand, we won't replace the whole msgs row, because this way, it will just work if an edit-message is received, and then later the user requests to download the attachment.
    • Need to change Viewtype, probably metadata params like image size
  • pre-message gets Viewtype::Text in the database until downloaded
  • background_fetch should not download messages with the Chat-Is-Full-Message header.
  • background_fetch: If a large message without Chat-Is-Full-Message header. is received, the UI should be notified via an event. postponed
  • A read receipt should be shown already when the user saw the pre-message. feat: pre messages can now get read receipts #7433

API Changes:

  • all: change Message.get_filebytes - if message is not downloaded pre message, and metadata is available, then it returns the size that the file has after download, so ui can use this to show download size
  • duration and dimensions (width, heigth) are already set in pre-messages (if they contain that metadata)
  • rust: add Message.get_full_message_viewtype to get view type that message will have after being downloaded.
  • jsonrpc: add full_message_view_type to Message and MessageInfo

@Simon-Laux Simon-Laux force-pushed the simon/sending-pre-message branch 3 times, most recently from 2b900c3 to 305498d Compare November 16, 2025 20:07
@Simon-Laux Simon-Laux force-pushed the simon/receive-pre-messages branch 4 times, most recently from b94964a to ce97ba3 Compare November 23, 2025 02:27
@Simon-Laux Simon-Laux force-pushed the simon/receive-pre-messages branch from cd716c5 to 4c14566 Compare November 26, 2025 14:13
Base automatically changed from simon/sending-pre-message to pre-messages November 26, 2025 14:14
@Simon-Laux Simon-Laux force-pushed the simon/receive-pre-messages branch from 4c14566 to ca6bf65 Compare November 26, 2025 15:09
"DELETE FROM download WHERE rfc724_mid=?",
(&msg.rfc724_mid,),
)?;
// TODO: is the following nessesary?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • TODO: answer the question

@Hocuri
Copy link
Collaborator

Hocuri commented Dec 1, 2025

background_fetch: If a large message without Chat-Is-Full-Message header. is received, the UI should be notified via an event.

  • rust: add Message.get_full_message_viewtype to get view type that message will have after being downloaded.

  • jsonrpc: add full_message_view_type to Message and MessageInfo

In the first iteration, it's not necessary to emit an event, or add any new API. (not sure how the event landed in the "steps" at #7367, but it already is in the "Future Possibilities")

@Simon-Laux Simon-Laux marked this pull request as ready for review December 1, 2025 15:46

/// Download known full messages without pre_message
/// in order to guard against lost pre-messages:
// TODO better fn name
Copy link
Contributor Author

Choose a reason for hiding this comment

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

any ideas for a better function name?


chat::mark_old_messages_as_noticed(context, received_msgs).await?;

// TODO: is there correct place for this?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

address to do comment

if let Some(full_msg_rfc724_mid) =
mail.headers.get_header_value(HeaderDef::ChatFullMessageId)
{
// TODO: is there a better method for this task? (removing `<>` delimiters of RFC message ID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • address to do comment

.context("delete_expired_imap_messages")?;

//-------
// TODO: verify that this is the correct position for this call
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • address todo comment

@Simon-Laux
Copy link
Contributor Author

Simon-Laux commented Dec 1, 2025

Progress of the tests

Overview about the recycled(♻️) and dropped(🗑️) tests of the tests that I removed in #7373

All the recycled tests were already recycled/re-made except for some which are still to do:

  • test_partial_group_consistency
  • test_msg_seen_on_imap_when_downloaded
  • test_download_limit_chat_assignment

Furthermore there need to be new tests to test the downloading/scheduling changes.

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.

3 participants