-
-
Notifications
You must be signed in to change notification settings - Fork 112
remove: partial downloads (remove creation of the stub messages) #7373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Simon-Laux
merged 26 commits into
pre-messages
from
simon/remove-partial-download-of-messages
Nov 14, 2025
+159
−1,312
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
cca4174
remove: partial downloads
Simon-Laux fdcb222
remove partial download tests and fix issues in other tests
Simon-Laux 7f3eabc
remove remaining partial messages tests
Simon-Laux 2e2bc12
remove download limit validation, it does not really matter in the new
Simon-Laux 902a0d7
fix clippy
Simon-Laux 70d7e04
ignore that `partial_download_msg_body` is dead code
Simon-Laux 2284d36
remove test for download limit validation
Simon-Laux 53163ab
remove `test_download_on_demand`
Simon-Laux cc9fe5d
remove test `test_download_limit_chat_assignment`
Simon-Laux d1dc322
Remove superfluous parentheses.
Simon-Laux 58ad664
fix the issue that broke the imap fetching
Simon-Laux 014d80b
fix python lint errors
Simon-Laux a044436
remove cffi python test`test_webxdc_download_on_demand`
Simon-Laux 28cca8b
fix python lint
Simon-Laux 560e86b
fix rebase issue
Simon-Laux 5a2ca7a
fix another rebase issue
Simon-Laux 10c2016
fix lint of python test
Simon-Laux 37b027a
reintroduce `Config::FailOnReceivingFullMsg` but renamed it to
Simon-Laux afa46c8
allow exclusion of `simulate_receive_imf_error` from get_info
Simon-Laux 6d11e08
adapt comment
Simon-Laux 05a1967
remove `StockMessage::PartialDownloadMsgBody`
Simon-Laux b70a41f
fix clippy issue
Simon-Laux 971286b
restore test `test_downloadstate_values`
Simon-Laux af00375
restore test `test_webxdc_update_for_not_downloaded_instance` and rename
Simon-Laux ab1fdfa
bring back receiving half of `test_partial_receive_imf` and rename to
Simon-Laux f7d8812
remove `test_webxdc_update_for_not_yet_received_instance`
Simon-Laux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
remove partial download tests and fix issues in other tests
- Loading branch information
commit fdcb2227bf0e33f34c1c4ab4aca77b7fcfa162f3
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -652,20 +652,13 @@ async fn test_no_partial_calls() -> Result<()> { | |
| Chat-Content: call-ended\n\ | ||
| \n\ | ||
| Call ended\n"; | ||
| receive_imf_from_inbox( | ||
| alice, | ||
| "[email protected]", | ||
| imf_raw, | ||
| seen, | ||
| Some(imf_raw.len().try_into().unwrap()), | ||
| ) | ||
| .await?; | ||
| receive_imf_from_inbox(alice, "[email protected]", imf_raw, seen).await?; | ||
|
|
||
| // The call is still not ended. | ||
| assert_eq!(call_state(alice, call_msg.id).await?, CallState::Alerting); | ||
|
|
||
| // Fully downloading the message ends the call. | ||
| receive_imf_from_inbox(alice, "[email protected]", imf_raw, seen, None) | ||
| receive_imf_from_inbox(alice, "[email protected]", imf_raw, seen) | ||
| .await | ||
| .context("Failed to fully download end call message")?; | ||
| assert_eq!(call_state(alice, call_msg.id).await?, CallState::Missed); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,11 +218,8 @@ mod tests { | |
| use num_traits::FromPrimitive; | ||
|
|
||
| use super::*; | ||
| use crate::chat::{get_chat_msgs, send_msg}; | ||
| use crate::ephemeral::Timer; | ||
| use crate::message::delete_msgs; | ||
| use crate::receive_imf::receive_imf_from_inbox; | ||
| use crate::test_utils::{E2EE_INFO_MSGS, TestContext, TestContextManager}; | ||
| use crate::chat::send_msg; | ||
| use crate::test_utils::TestContext; | ||
|
|
||
| #[test] | ||
| fn test_downloadstate_values() { | ||
|
|
@@ -294,230 +291,4 @@ mod tests { | |
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
| async fn test_partial_receive_imf() -> Result<()> { | ||
Simon-Laux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let t = TestContext::new_alice().await; | ||
|
|
||
| let header = "Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\ | ||
| From: [email protected]\n\ | ||
| To: [email protected]\n\ | ||
| Subject: foo\n\ | ||
| Message-ID: <[email protected]>\n\ | ||
| Chat-Version: 1.0\n\ | ||
| Date: Sun, 22 Mar 2020 22:37:57 +0000\ | ||
| Content-Type: text/plain"; | ||
|
|
||
| receive_imf_from_inbox( | ||
| &t, | ||
| "[email protected]", | ||
| header.as_bytes(), | ||
| false, | ||
| Some(100000), | ||
| ) | ||
| .await?; | ||
| let msg = t.get_last_msg().await; | ||
| assert_eq!(msg.download_state(), DownloadState::Available); | ||
| assert_eq!(msg.get_subject(), "foo"); | ||
| assert!( | ||
| msg.get_text() | ||
| .contains(&stock_str::partial_download_msg_body(&t, 100000).await) | ||
| ); | ||
|
|
||
| receive_imf_from_inbox( | ||
| &t, | ||
| "[email protected]", | ||
| format!("{header}\n\n100k text...").as_bytes(), | ||
| false, | ||
| None, | ||
| ) | ||
| .await?; | ||
| let msg = t.get_last_msg().await; | ||
| assert_eq!(msg.download_state(), DownloadState::Done); | ||
| assert_eq!(msg.get_subject(), "foo"); | ||
| assert_eq!(msg.get_text(), "100k text..."); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
| async fn test_partial_download_and_ephemeral() -> Result<()> { | ||
| let t = TestContext::new_alice().await; | ||
| let chat_id = t | ||
| .create_chat_with_contact("bob", "[email protected]") | ||
| .await | ||
| .id; | ||
| chat_id | ||
| .set_ephemeral_timer(&t, Timer::Enabled { duration: 60 }) | ||
| .await?; | ||
|
|
||
| // download message from bob partially, this must not change the ephemeral timer | ||
| receive_imf_from_inbox( | ||
| &t, | ||
| "[email protected]", | ||
| b"From: Bob <[email protected]>\n\ | ||
| To: Alice <[email protected]>\n\ | ||
| Chat-Version: 1.0\n\ | ||
| Subject: subject\n\ | ||
| Message-ID: <[email protected]>\n\ | ||
| Date: Sun, 14 Nov 2021 00:10:00 +0000\ | ||
| Content-Type: text/plain", | ||
| false, | ||
| Some(100000), | ||
| ) | ||
| .await?; | ||
| assert_eq!( | ||
| chat_id.get_ephemeral_timer(&t).await?, | ||
| Timer::Enabled { duration: 60 } | ||
| ); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
| async fn test_status_update_expands_to_nothing() -> Result<()> { | ||
| let alice = TestContext::new_alice().await; | ||
| let bob = TestContext::new_bob().await; | ||
| let chat_id = alice.create_chat(&bob).await.id; | ||
|
|
||
| let file = alice.get_blobdir().join("minimal.xdc"); | ||
| tokio::fs::write(&file, include_bytes!("../test-data/webxdc/minimal.xdc")).await?; | ||
| let mut instance = Message::new(Viewtype::File); | ||
| instance.set_file_and_deduplicate(&alice, &file, None, None)?; | ||
| let _sent1 = alice.send_msg(chat_id, &mut instance).await; | ||
|
|
||
| alice | ||
| .send_webxdc_status_update(instance.id, r#"{"payload":7}"#) | ||
| .await?; | ||
| alice.flush_status_updates().await?; | ||
| let sent2 = alice.pop_sent_msg().await; | ||
| let sent2_rfc724_mid = sent2.load_from_db().await.rfc724_mid; | ||
|
|
||
| // not downloading the status update results in an placeholder | ||
| receive_imf_from_inbox( | ||
| &bob, | ||
| &sent2_rfc724_mid, | ||
| sent2.payload().as_bytes(), | ||
| false, | ||
| Some(sent2.payload().len() as u32), | ||
| ) | ||
| .await?; | ||
| let msg = bob.get_last_msg().await; | ||
| let chat_id = msg.chat_id; | ||
| assert_eq!( | ||
| get_chat_msgs(&bob, chat_id).await?.len(), | ||
| E2EE_INFO_MSGS + 1 | ||
| ); | ||
| assert_eq!(msg.download_state(), DownloadState::Available); | ||
|
|
||
| // downloading the status update afterwards expands to nothing and moves the placeholder to trash-chat | ||
| // (usually status updates are too small for not being downloaded directly) | ||
| receive_imf_from_inbox( | ||
| &bob, | ||
| &sent2_rfc724_mid, | ||
| sent2.payload().as_bytes(), | ||
| false, | ||
| None, | ||
| ) | ||
| .await?; | ||
| assert_eq!(get_chat_msgs(&bob, chat_id).await?.len(), E2EE_INFO_MSGS); | ||
| assert!( | ||
| Message::load_from_db_optional(&bob, msg.id) | ||
| .await? | ||
| .is_none() | ||
| ); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
| async fn test_mdn_expands_to_nothing() -> Result<()> { | ||
| let bob = TestContext::new_bob().await; | ||
| let raw = b"Subject: Message opened\n\ | ||
| Date: Mon, 10 Jan 2020 00:00:00 +0000\n\ | ||
| Chat-Version: 1.0\n\ | ||
| Message-ID: <[email protected]>\n\ | ||
| To: Alice <[email protected]>\n\ | ||
| From: Bob <[email protected]>\n\ | ||
| Content-Type: multipart/report; report-type=disposition-notification;\n\t\ | ||
| boundary=\"kJBbU58X1xeWNHgBtTbMk80M5qnV4N\"\n\ | ||
| \n\ | ||
| \n\ | ||
| --kJBbU58X1xeWNHgBtTbMk80M5qnV4N\n\ | ||
| Content-Type: text/plain; charset=utf-8\n\ | ||
| \n\ | ||
| bla\n\ | ||
| \n\ | ||
| \n\ | ||
| --kJBbU58X1xeWNHgBtTbMk80M5qnV4N\n\ | ||
| Content-Type: message/disposition-notification\n\ | ||
| \n\ | ||
| Reporting-UA: Delta Chat 1.88.0\n\ | ||
| Original-Recipient: rfc822;[email protected]\n\ | ||
| Final-Recipient: rfc822;[email protected]\n\ | ||
| Original-Message-ID: <[email protected]>\n\ | ||
| Disposition: manual-action/MDN-sent-automatically; displayed\n\ | ||
| \n\ | ||
| \n\ | ||
| --kJBbU58X1xeWNHgBtTbMk80M5qnV4N--\n\ | ||
| "; | ||
|
|
||
| // not downloading the mdn results in an placeholder | ||
| receive_imf_from_inbox(&bob, "[email protected]", raw, false, Some(raw.len() as u32)).await?; | ||
| let msg = bob.get_last_msg().await; | ||
| let chat_id = msg.chat_id; | ||
| assert_eq!(get_chat_msgs(&bob, chat_id).await?.len(), 1); | ||
| assert_eq!(msg.download_state(), DownloadState::Available); | ||
|
|
||
| // downloading the mdn afterwards expands to nothing and deletes the placeholder directly | ||
| // (usually mdn are too small for not being downloaded directly) | ||
| receive_imf_from_inbox(&bob, "[email protected]", raw, false, None).await?; | ||
| assert_eq!(get_chat_msgs(&bob, chat_id).await?.len(), 0); | ||
| assert!( | ||
| Message::load_from_db_optional(&bob, msg.id) | ||
| .await? | ||
| .is_none() | ||
| ); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| /// Tests that fully downloading the message | ||
| /// works even if the Message-ID already exists | ||
| /// in the database assigned to the trash chat. | ||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
| async fn test_partial_download_trashed() -> Result<()> { | ||
| let mut tcm = TestContextManager::new(); | ||
| let alice = &tcm.alice().await; | ||
|
|
||
| let imf_raw = b"From: Bob <[email protected]>\n\ | ||
| To: Alice <[email protected]>\n\ | ||
| Chat-Version: 1.0\n\ | ||
| Subject: subject\n\ | ||
| Message-ID: <[email protected]>\n\ | ||
| Date: Sun, 14 Nov 2021 00:10:00 +0000\ | ||
| Content-Type: text/plain"; | ||
|
|
||
| // Download message from Bob partially. | ||
| let partial_received_msg = | ||
| receive_imf_from_inbox(alice, "[email protected]", imf_raw, false, Some(100000)) | ||
| .await? | ||
| .unwrap(); | ||
| assert_eq!(partial_received_msg.msg_ids.len(), 1); | ||
|
|
||
| // Delete the received message. | ||
| // Not it is still in the database, | ||
| // but in the trash chat. | ||
| delete_msgs(alice, &[partial_received_msg.msg_ids[0]]).await?; | ||
|
|
||
| // Fully download message after deletion. | ||
| let full_received_msg = | ||
| receive_imf_from_inbox(alice, "[email protected]", imf_raw, false, None).await?; | ||
|
|
||
| // The message does not reappear. | ||
| // However, `receive_imf` should not fail. | ||
| assert!(full_received_msg.is_none()); | ||
|
|
||
| Ok(()) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.