mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
@@ -1134,9 +1134,10 @@ class TestOnlineAccount:
|
|||||||
|
|
||||||
def test_dont_show_emails_in_draft_folder(self, acfactory):
|
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.
|
"""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 = acfactory.get_online_configuring_account()
|
||||||
ac1.set_config("show_emails", "2")
|
ac1.set_config("show_emails", "2")
|
||||||
|
ac1.create_contact("alice@example.com").create_chat()
|
||||||
|
|
||||||
acfactory.wait_configure(ac1)
|
acfactory.wait_configure(ac1)
|
||||||
ac1.direct_imap.create_folder("Drafts")
|
ac1.direct_imap.create_folder("Drafts")
|
||||||
@@ -1148,23 +1149,23 @@ class TestOnlineAccount:
|
|||||||
ac1.stop_io()
|
ac1.stop_io()
|
||||||
|
|
||||||
ac1.direct_imap.append("Drafts", """
|
ac1.direct_imap.append("Drafts", """
|
||||||
From: Bob <bob@example.org>
|
From: ac1 <{}>
|
||||||
Subject: subj
|
Subject: subj
|
||||||
To: alice@example.com
|
To: alice@example.com
|
||||||
Message-ID: <aepiors@example.org>
|
Message-ID: <aepiors@example.org>
|
||||||
Content-Type: text/plain; charset=utf-8
|
Content-Type: text/plain; charset=utf-8
|
||||||
|
|
||||||
message in Drafts
|
message in Drafts
|
||||||
""")
|
""".format(ac1.get_config("configured_addr")))
|
||||||
ac1.direct_imap.append("Sent", """
|
ac1.direct_imap.append("Sent", """
|
||||||
From: Bob <bob@example.org>
|
From: ac1 <{}>
|
||||||
Subject: subj
|
Subject: subj
|
||||||
To: alice@example.com
|
To: alice@example.com
|
||||||
Message-ID: <hsabaeni@example.org>
|
Message-ID: <hsabaeni@example.org>
|
||||||
Content-Type: text/plain; charset=utf-8
|
Content-Type: text/plain; charset=utf-8
|
||||||
|
|
||||||
message in Sent
|
message in Sent
|
||||||
""")
|
""".format(ac1.get_config("configured_addr")))
|
||||||
|
|
||||||
ac1.set_config("scan_all_folders_debounce_secs", "0")
|
ac1.set_config("scan_all_folders_debounce_secs", "0")
|
||||||
ac1.start_io()
|
ac1.start_io()
|
||||||
|
|||||||
@@ -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:
|
// 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
|
// - 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
|
// - 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 !to_ids.is_empty() {
|
||||||
if chat_id.is_unset() {
|
if chat_id.is_unset() {
|
||||||
let (new_chat_id, new_chat_id_blocked) = create_or_lookup_group(
|
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();
|
let chat_id = chat::create_by_contact_id(&t, contact_id).await.unwrap();
|
||||||
dc_receive_imf(
|
dc_receive_imf(
|
||||||
&t,
|
&t,
|
||||||
b"Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\
|
b"From: =?UTF-8?B?0JjQvNGPLCDQpNCw0LzQuNC70LjRjw==?= <foobar@example.com>\n\
|
||||||
From: =?UTF-8?B?0JjQvNGPLCDQpNCw0LzQuNC70LjRjw==?= <foobar@example.com>\n\
|
|
||||||
To: alice@example.com\n\
|
To: alice@example.com\n\
|
||||||
Subject: foo\n\
|
Subject: foo\n\
|
||||||
Message-ID: <asdklfjjaweofi@example.com>\n\
|
Message-ID: <asdklfjjaweofi@example.com>\n\
|
||||||
@@ -2413,8 +2414,7 @@ mod tests {
|
|||||||
|
|
||||||
dc_receive_imf(
|
dc_receive_imf(
|
||||||
&t,
|
&t,
|
||||||
b"Received: (Postfix, from userid 1000); Mon, 4 Dec 2006 14:51:39 +0100 (CET)\n\
|
b"From: Foobar <foobar@example.com>\n\
|
||||||
From: Foobar <foobar@example.com>\n\
|
|
||||||
To: =?UTF-8?B?0JjQvNGPLCDQpNCw0LzQuNC70LjRjw==?= alice@example.com\n\
|
To: =?UTF-8?B?0JjQvNGPLCDQpNCw0LzQuNC70LjRjw==?= alice@example.com\n\
|
||||||
Cc: =?utf-8?q?=3Ch2=3E?= <carl@host.tld>\n\
|
Cc: =?utf-8?q?=3Ch2=3E?= <carl@host.tld>\n\
|
||||||
Subject: foo\n\
|
Subject: foo\n\
|
||||||
|
|||||||
Reference in New Issue
Block a user