diff --git a/python/tests/test_account.py b/python/tests/test_account.py index cbf3ffde6..557b10a8d 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -1134,9 +1134,10 @@ class TestOnlineAccount: def test_dont_show_emails_in_draft_folder(self, acfactory): """Most mailboxes have a "Drafts" folder where constantly new emails appear but we don't actually want to show them. - So: If there is no Received header AND it's not in the sentbox, then ignore the email.""" + So: If it's outgoing AND there is no Received header AND it's not in the sentbox, then ignore the email.""" ac1 = acfactory.get_online_configuring_account() ac1.set_config("show_emails", "2") + ac1.create_contact("alice@example.com").create_chat() acfactory.wait_configure(ac1) ac1.direct_imap.create_folder("Drafts") @@ -1148,23 +1149,23 @@ class TestOnlineAccount: ac1.stop_io() ac1.direct_imap.append("Drafts", """ - From: Bob + From: ac1 <{}> Subject: subj To: alice@example.com Message-ID: Content-Type: text/plain; charset=utf-8 message in Drafts - """) + """.format(ac1.get_config("configured_addr"))) ac1.direct_imap.append("Sent", """ - From: Bob + From: ac1 <{}> Subject: subj To: alice@example.com Message-ID: Content-Type: text/plain; charset=utf-8 message in Sent - """) + """.format(ac1.get_config("configured_addr"))) ac1.set_config("scan_all_folders_debounce_secs", "0") ac1.start_io() diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 25c77477a..8869a4455 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -407,14 +407,6 @@ async fn add_parts( } } - if !context.is_sentbox(&server_folder).await && mime_parser.get(HeaderDef::Received).is_none() { - // Most mailboxes have a "Drafts" folder where constantly new emails appear but we don't actually want to show them - // So: If there is no Received header AND it's not in the sentbox, then ignore the email. - info!(context, "Email is probably just a draft (TRASH)"); - *chat_id = ChatId::new(DC_CHAT_ID_TRASH); - allow_creation = false; - } - // check if the message introduces a new chat: // - outgoing messages introduce a chat with the first to: address if they are sent by a messenger // - incoming messages introduce a chat only for known contacts if they are sent by a messenger @@ -597,6 +589,16 @@ async fn add_parts( } } + if !context.is_sentbox(&server_folder).await + && mime_parser.get(HeaderDef::Received).is_none() + { + // Most mailboxes have a "Drafts" folder where constantly new emails appear but we don't actually want to show them + // So: If it's outgoing AND there is no Received header AND it's not in the sentbox, then ignore the email. + info!(context, "Email is probably just a draft (TRASH)"); + *chat_id = ChatId::new(DC_CHAT_ID_TRASH); + allow_creation = false; + } + if !to_ids.is_empty() { if chat_id.is_unset() { let (new_chat_id, new_chat_id_blocked) = create_or_lookup_group( @@ -2364,8 +2366,7 @@ mod tests { let chat_id = chat::create_by_contact_id(&t, contact_id).await.unwrap(); dc_receive_imf( &t, - b"Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\ - From: =?UTF-8?B?0JjQvNGPLCDQpNCw0LzQuNC70LjRjw==?= \n\ + b"From: =?UTF-8?B?0JjQvNGPLCDQpNCw0LzQuNC70LjRjw==?= \n\ To: alice@example.com\n\ Subject: foo\n\ Message-ID: \n\ @@ -2413,8 +2414,7 @@ mod tests { dc_receive_imf( &t, - b"Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\ - From: Foobar \n\ + b"From: Foobar \n\ To: =?UTF-8?B?0JjQvNGPLCDQpNCw0LzQuNC70LjRjw==?= alice@example.com\n\ Cc: =?utf-8?q?=3Ch2=3E?= \n\ Subject: foo\n\