-
-
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
Merged
Changes from all commits
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
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
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 |
|---|---|---|
|
|
@@ -336,7 +336,7 @@ def test_receive_imf_failure(acfactory) -> None: | |
| alice_contact_bob = alice.create_contact(bob, "Bob") | ||
| alice_chat_bob = alice_contact_bob.create_chat() | ||
|
|
||
| bob.set_config("fail_on_receiving_full_msg", "1") | ||
| bob.set_config("simulate_receive_imf_error", "1") | ||
| alice_chat_bob.send_text("Hello!") | ||
| event = bob.wait_for_event(EventType.MSGS_CHANGED) | ||
| assert event.chat_id == bob.get_device_chat().id | ||
|
|
@@ -345,12 +345,12 @@ def test_receive_imf_failure(acfactory) -> None: | |
| snapshot = message.get_snapshot() | ||
| assert ( | ||
| snapshot.text == "❌ Failed to receive a message:" | ||
| " Condition failed: `!context.get_config_bool(Config::FailOnReceivingFullMsg).await?`." | ||
| " Condition failed: `!context.get_config_bool(Config::SimulateReceiveImfError).await?`." | ||
| " Please report this bug to [email protected] or https://support.delta.chat/." | ||
| ) | ||
|
|
||
| # The failed message doesn't break the IMAP loop. | ||
| bob.set_config("fail_on_receiving_full_msg", "0") | ||
| bob.set_config("simulate_receive_imf_error", "0") | ||
| alice_chat_bob.send_text("Hello again!") | ||
| event = bob.wait_for_incoming_msg_event() | ||
| msg_id = event.msg_id | ||
|
|
@@ -604,60 +604,6 @@ def test_mdn_doesnt_break_autocrypt(acfactory) -> None: | |
| assert snapshot.show_padlock | ||
|
|
||
|
|
||
| def test_reaction_to_partially_fetched_msg(acfactory, tmp_path): | ||
| """See https://github.com/deltachat/deltachat-core-rust/issues/3688 "Partially downloaded | ||
| messages are received out of order". | ||
|
|
||
| If the Inbox contains X small messages followed by Y large messages followed by Z small | ||
| messages, Delta Chat first downloaded a batch of X+Z messages, and then a batch of Y messages. | ||
|
|
||
| This bug was discovered by @Simon-Laux while testing reactions PR #3644 and can be reproduced | ||
| with online test as follows: | ||
| - Bob enables download limit and goes offline. | ||
| - Alice sends a large message to Bob and reacts to this message with a thumbs-up. | ||
| - Bob goes online | ||
| - Bob first processes a reaction message and throws it away because there is no corresponding | ||
| message, then processes a partially downloaded message. | ||
| - As a result, Bob does not see a reaction | ||
| """ | ||
| download_limit = 300000 | ||
| ac1, ac2 = acfactory.get_online_accounts(2) | ||
| ac1_addr = ac1.get_config("addr") | ||
| chat = ac1.create_chat(ac2) | ||
| ac2.set_config("download_limit", str(download_limit)) | ||
| ac2.stop_io() | ||
|
|
||
| logging.info("sending small+large messages from ac1 to ac2") | ||
| msgs = [] | ||
| msgs.append(chat.send_text("hi")) | ||
| path = tmp_path / "large" | ||
| path.write_bytes(os.urandom(download_limit + 1)) | ||
| msgs.append(chat.send_file(str(path))) | ||
| for m in msgs: | ||
| m.wait_until_delivered() | ||
|
|
||
| logging.info("sending a reaction to the large message from ac1 to ac2") | ||
| # TODO: Find the reason of an occasional message reordering on the server (so that the reaction | ||
| # has a lower UID than the previous message). W/a is to sleep for some time to let the reaction | ||
| # have a later INTERNALDATE. | ||
| time.sleep(1.1) | ||
| react_str = "\N{THUMBS UP SIGN}" | ||
| msgs.append(msgs[-1].send_reaction(react_str)) | ||
| msgs[-1].wait_until_delivered() | ||
|
|
||
| ac2.start_io() | ||
|
|
||
| logging.info("wait for ac2 to receive a reaction") | ||
| msg2 = Message(ac2, ac2.wait_for_reactions_changed().msg_id) | ||
| assert msg2.get_sender_contact().get_snapshot().address == ac1_addr | ||
| assert msg2.get_snapshot().download_state == DownloadState.AVAILABLE | ||
| reactions = msg2.get_reactions() | ||
| contacts = [Contact(ac2, int(i)) for i in reactions.reactions_by_contact] | ||
| assert len(contacts) == 1 | ||
| assert contacts[0].get_snapshot().address == ac1_addr | ||
| assert list(reactions.reactions_by_contact.values())[0] == [react_str] | ||
|
|
||
|
|
||
| def test_reactions_for_a_reordering_move(acfactory, direct_imap): | ||
| """When a batch of messages is moved from Inbox to DeltaChat folder with a single MOVE command, | ||
| their UIDs may be reordered (e.g. Gmail is known for that) which led to that messages were | ||
|
|
@@ -702,50 +648,6 @@ def test_reactions_for_a_reordering_move(acfactory, direct_imap): | |
| assert list(reactions.reactions_by_contact.values())[0] == [react_str] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("n_accounts", [3, 2]) | ||
| def test_download_limit_chat_assignment(acfactory, tmp_path, n_accounts): | ||
| download_limit = 300000 | ||
|
|
||
| alice, *others = acfactory.get_online_accounts(n_accounts) | ||
| bob = others[0] | ||
|
|
||
| alice_group = alice.create_group("test group") | ||
| for account in others: | ||
| chat = account.create_chat(alice) | ||
| chat.send_text("Hello Alice!") | ||
| assert alice.get_message_by_id(alice.wait_for_incoming_msg_event().msg_id).get_snapshot().text == "Hello Alice!" | ||
|
|
||
| contact = alice.create_contact(account) | ||
| alice_group.add_contact(contact) | ||
|
|
||
| if n_accounts == 2: | ||
| bob_chat_alice = bob.create_chat(alice) | ||
| bob.set_config("download_limit", str(download_limit)) | ||
|
|
||
| alice_group.send_text("hi") | ||
| snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot() | ||
| assert snapshot.text == "hi" | ||
| bob_group = snapshot.chat | ||
|
|
||
| path = tmp_path / "large" | ||
| path.write_bytes(os.urandom(download_limit + 1)) | ||
|
|
||
| for i in range(10): | ||
| logging.info("Sending message %s", i) | ||
| alice_group.send_file(str(path)) | ||
| snapshot = bob.get_message_by_id(bob.wait_for_incoming_msg_event().msg_id).get_snapshot() | ||
| assert snapshot.download_state == DownloadState.AVAILABLE | ||
| if n_accounts > 2: | ||
| assert snapshot.chat == bob_group | ||
| else: | ||
| # Group contains only Alice and Bob, | ||
| # so partially downloaded messages are | ||
| # hard to distinguish from private replies to group messages. | ||
| # | ||
| # Message may be a private reply, so we assign it to 1:1 chat with Alice. | ||
| assert snapshot.chat == bob_chat_alice | ||
|
|
||
|
|
||
| def test_markseen_contact_request(acfactory): | ||
| """ | ||
| Test that seen status is synchronized for contact request messages | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ use super::*; | |
| use crate::chat::forward_msgs; | ||
| use crate::config::Config; | ||
| use crate::constants::DC_CHAT_ID_TRASH; | ||
| use crate::receive_imf::{receive_imf, receive_imf_from_inbox}; | ||
| use crate::receive_imf::receive_imf; | ||
| use crate::test_utils::{TestContext, TestContextManager}; | ||
|
|
||
| struct CallSetup { | ||
|
|
@@ -610,65 +610,3 @@ async fn test_end_text_call() -> Result<()> { | |
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| /// Tests that partially downloaded "call ended" | ||
| /// messages are not processed. | ||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
| async fn test_no_partial_calls() -> Result<()> { | ||
| let mut tcm = TestContextManager::new(); | ||
| let alice = &tcm.alice().await; | ||
|
|
||
| let seen = false; | ||
|
|
||
| // The messages in the test | ||
| // have no `Date` on purpose, | ||
| // so they are treated as new. | ||
| let received_call = receive_imf( | ||
| alice, | ||
| b"From: [email protected]\n\ | ||
| To: [email protected]\n\ | ||
| Message-ID: <[email protected]>\n\ | ||
| Chat-Version: 1.0\n\ | ||
| Chat-Content: call\n\ | ||
| Chat-Webrtc-Room: YWFhYWFhYWFhCg==\n\ | ||
| \n\ | ||
| Hello, this is a call\n", | ||
| seen, | ||
| ) | ||
| .await? | ||
| .unwrap(); | ||
| assert_eq!(received_call.msg_ids.len(), 1); | ||
| let call_msg = Message::load_from_db(alice, received_call.msg_ids[0]) | ||
| .await | ||
| .unwrap(); | ||
| assert_eq!(call_msg.viewtype, Viewtype::Call); | ||
| assert_eq!(call_state(alice, call_msg.id).await?, CallState::Alerting); | ||
|
|
||
| let imf_raw = b"From: [email protected]\n\ | ||
| To: [email protected]\n\ | ||
| Message-ID: <[email protected]>\n\ | ||
| In-Reply-To: <[email protected]>\n\ | ||
| Chat-Version: 1.0\n\ | ||
| 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?; | ||
|
|
||
| // 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) | ||
| .await | ||
| .context("Failed to fully download end call message")?; | ||
| assert_eq!(call_state(alice, call_msg.id).await?, CallState::Missed); | ||
|
|
||
| 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
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
Oops, something went wrong.
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.