Skip to content

Commit e9b13de

Browse files
committed
feat: Remove Config::ConfiguredSentboxFolder
It's used in `fetch_existing_msgs()`, but we can remove it and tell users that they need to move/copy messages from Sentbox to Inbox so that Delta Chat adds all contacts from them. This way users will be also informed that Delta Chat needs users to CC/BCC/To themselves to see messages sent from other MUAs.
1 parent c9180d6 commit e9b13de

File tree

7 files changed

+31
-67
lines changed

7 files changed

+31
-67
lines changed

python/tests/test_1_online.py

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def test_enable_mvbox_move(acfactory, lp):
269269
assert ac2._evtracker.wait_next_incoming_message().text == "message1"
270270

271271

272-
def test_mvbox_thread_and_sentbox(acfactory, lp):
272+
def test_mvbox_thread_and_trash(acfactory, lp):
273273
lp.sec("ac1: start with mvbox thread")
274274
ac1 = acfactory.new_online_configuring_account(mvbox_move=True)
275275

@@ -279,8 +279,8 @@ def test_mvbox_thread_and_sentbox(acfactory, lp):
279279
lp.sec("ac2 and ac1: waiting for configuration")
280280
acfactory.bring_accounts_online()
281281

282-
lp.sec("ac1: create sentbox")
283-
ac1.direct_imap.create_folder("Sent")
282+
lp.sec("ac1: create trash")
283+
ac1.direct_imap.create_folder("Trash")
284284
ac1.set_config("scan_all_folders_debounce_secs", "0")
285285
ac1.stop_io()
286286
ac1.start_io()
@@ -290,7 +290,7 @@ def test_mvbox_thread_and_sentbox(acfactory, lp):
290290
assert ac2._evtracker.wait_next_incoming_message().text == "message1"
291291

292292
assert ac1.get_config("configured_mvbox_folder") == "DeltaChat"
293-
while ac1.get_config("configured_sentbox_folder") != "Sent":
293+
while ac1.get_config("configured_trash_folder") != "Trash":
294294
ac1._evtracker.get_matching("DC_EVENT_CONNECTIVITY_CHANGED")
295295

296296

@@ -834,9 +834,9 @@ def test_no_draft_if_cant_send(acfactory):
834834

835835
def test_dont_show_emails(acfactory, lp):
836836
"""Most mailboxes have a "Drafts" folder where constantly new emails appear but we don't actually want to show them.
837-
So: If it's outgoing AND there is no Received header AND it's not in the sentbox, then ignore the email.
837+
So: If it's outgoing AND there is no Received header, then ignore the email.
838838
839-
If the draft email is sent out later (i.e. moved to "Sent"), it must be shown.
839+
If the draft email is sent out and received later (i.e. it's in "Inbox"), it must be shown.
840840
841841
Also, test that unknown emails in the Spam folder are not shown."""
842842
ac1 = acfactory.new_online_configuring_account()
@@ -845,7 +845,6 @@ def test_dont_show_emails(acfactory, lp):
845845

846846
acfactory.wait_configured(ac1)
847847
ac1.direct_imap.create_folder("Drafts")
848-
ac1.direct_imap.create_folder("Sent")
849848
ac1.direct_imap.create_folder("Spam")
850849
ac1.direct_imap.create_folder("Junk")
851850

@@ -861,21 +860,7 @@ def test_dont_show_emails(acfactory, lp):
861860
Message-ID: <[email protected]>
862861
Content-Type: text/plain; charset=utf-8
863862
864-
message in Drafts that is moved to Sent later
865-
""".format(
866-
ac1.get_config("configured_addr"),
867-
),
868-
)
869-
ac1.direct_imap.append(
870-
"Sent",
871-
"""
872-
From: ac1 <{}>
873-
Subject: subj
874-
875-
Message-ID: <[email protected]>
876-
Content-Type: text/plain; charset=utf-8
877-
878-
message in Sent
863+
message in Drafts received later
879864
""".format(
880865
ac1.get_config("configured_addr"),
881866
),
@@ -955,31 +940,31 @@ def test_dont_show_emails(acfactory, lp):
955940
lp.sec("All prepared, now let DC find the message")
956941
ac1.start_io()
957942

958-
msg = ac1._evtracker.wait_next_messages_changed()
959-
960943
# Wait until each folder was scanned, this is necessary for this test to test what it should test:
961944
ac1._evtracker.wait_idle_inbox_ready()
962945

963-
assert msg.text == "subj – message in Sent"
946+
fresh_msgs = list(ac1.get_fresh_messages())
947+
assert len(fresh_msgs) == 1
948+
msg = fresh_msgs[0]
964949
chat_msgs = msg.chat.get_messages()
965-
assert len(chat_msgs) == 2
950+
assert len(chat_msgs) == 1
966951
assert any(msg.text == "subj – Actually interesting message in Spam" for msg in chat_msgs)
967952

968953
assert not any("unknown.address" in c.get_name() for c in ac1.get_chats())
969954
ac1.direct_imap.select_folder("Spam")
970955
assert ac1.direct_imap.get_uid_by_message_id("[email protected]")
971956

972957
ac1.stop_io()
973-
lp.sec("'Send out' the draft, i.e. move it to the Sent folder, and wait for DC to display it this time")
958+
lp.sec("'Send out' the draft by moving it to Inbox, and wait for DC to display it this time")
974959
ac1.direct_imap.select_folder("Drafts")
975960
uid = ac1.direct_imap.get_uid_by_message_id("[email protected]")
976-
ac1.direct_imap.conn.move(uid, "Sent")
961+
ac1.direct_imap.conn.move(uid, "Inbox")
977962

978963
ac1.start_io()
979964
msg2 = ac1._evtracker.wait_next_messages_changed()
980965

981-
assert msg2.text == "subj – message in Drafts that is moved to Sent later"
982-
assert len(msg.chat.get_messages()) == 3
966+
assert msg2.text == "subj – message in Drafts received later"
967+
assert len(msg.chat.get_messages()) == 2
983968

984969

985970
def test_bot(acfactory, lp):

src/config.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,6 @@ pub enum Config {
281281
/// Configured folder for chat messages.
282282
ConfiguredMvboxFolder,
283283

284-
/// Configured "Sent" folder.
285-
ConfiguredSentboxFolder,
286-
287284
/// Configured "Trash" folder.
288285
ConfiguredTrashFolder,
289286

src/context.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,6 @@ impl Context {
861861
.get_config(Config::ConfiguredInboxFolder)
862862
.await?
863863
.unwrap_or_else(|| "<unset>".to_string());
864-
let configured_sentbox_folder = self
865-
.get_config(Config::ConfiguredSentboxFolder)
866-
.await?
867-
.unwrap_or_else(|| "<unset>".to_string());
868864
let configured_mvbox_folder = self
869865
.get_config(Config::ConfiguredMvboxFolder)
870866
.await?
@@ -960,7 +956,6 @@ impl Context {
960956
folders_configured.to_string(),
961957
);
962958
res.insert("configured_inbox_folder", configured_inbox_folder);
963-
res.insert("configured_sentbox_folder", configured_sentbox_folder);
964959
res.insert("configured_mvbox_folder", configured_mvbox_folder);
965960
res.insert("configured_trash_folder", configured_trash_folder);
966961
res.insert("mdns_enabled", mdns_enabled.to_string());

src/imap.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl FolderMeaning {
164164
FolderMeaning::Spam => None,
165165
FolderMeaning::Inbox => Some(Config::ConfiguredInboxFolder),
166166
FolderMeaning::Mvbox => Some(Config::ConfiguredMvboxFolder),
167-
FolderMeaning::Sent => Some(Config::ConfiguredSentboxFolder),
167+
FolderMeaning::Sent => None,
168168
FolderMeaning::Trash => Some(Config::ConfiguredTrashFolder),
169169
FolderMeaning::Drafts => None,
170170
FolderMeaning::Virtual => None,
@@ -790,9 +790,6 @@ impl Imap {
790790
context: &Context,
791791
session: &mut Session,
792792
) -> Result<()> {
793-
add_all_recipients_as_contacts(context, session, Config::ConfiguredSentboxFolder)
794-
.await
795-
.context("failed to get recipients from the sentbox")?;
796793
add_all_recipients_as_contacts(context, session, Config::ConfiguredMvboxFolder)
797794
.await
798795
.context("failed to get recipients from the movebox")?;
@@ -1980,7 +1977,7 @@ async fn spam_target_folder_cfg(
19801977
}
19811978
}
19821979

1983-
/// Returns `ConfiguredInboxFolder`, `ConfiguredMvboxFolder` or `ConfiguredSentboxFolder` if
1980+
/// Returns `ConfiguredInboxFolder` or `ConfiguredMvboxFolder` if
19841981
/// the message needs to be moved from `folder`. Otherwise returns `None`.
19851982
pub async fn target_folder_cfg(
19861983
context: &Context,

src/imap/imap_tests.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ async fn check_target_folder_combination(
119119
t.ctx
120120
.set_config(Config::ConfiguredMvboxFolder, Some("DeltaChat"))
121121
.await?;
122-
t.ctx
123-
.set_config(Config::ConfiguredSentboxFolder, Some("Sent"))
124-
.await?;
125122
t.ctx
126123
.set_config(Config::MvboxMove, Some(if mvbox_move { "1" } else { "0" }))
127124
.await?;

src/imap/scan_folders.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,15 @@ impl Imap {
8484
}
8585
}
8686

87-
// Set configs for necessary folders. Or reset if the folder was deleted.
88-
for conf in [
89-
Config::ConfiguredSentboxFolder,
90-
Config::ConfiguredTrashFolder,
91-
] {
92-
let val = folder_configs.get(&conf).map(|s| s.as_str());
93-
let interrupt = conf == Config::ConfiguredTrashFolder
94-
&& val.is_some()
95-
&& context.get_config(conf).await?.is_none();
96-
context.set_config_internal(conf, val).await?;
97-
if interrupt {
98-
// `Imap::fetch_move_delete()` is possible now for other folders (NB: we are in the
99-
// Inbox loop).
100-
context.scheduler.interrupt_oboxes().await;
101-
}
87+
// Set config for the Trash folder. Or reset if the folder was deleted.
88+
let conf = Config::ConfiguredTrashFolder;
89+
let val = folder_configs.get(&conf).map(|s| s.as_str());
90+
let interrupt = val.is_some() && context.get_config(conf).await?.is_none();
91+
context.set_config_internal(conf, val).await?;
92+
if interrupt {
93+
// `Imap::fetch_move_delete()`, particularly message deletion, is possible now for other
94+
// folders (NB: we are in the Inbox loop).
95+
context.scheduler.interrupt_oboxes().await;
10296
}
10397

10498
info!(context, "Found folders: {folder_names:?}.");

src/sql/migrations.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,19 +401,18 @@ UPDATE chats SET protected=1, type=120 WHERE type=130;"#,
401401
.await?;
402402
}
403403
if dbversion < 73 {
404-
use Config::*;
405404
sql.execute(
406405
r#"
407406
CREATE TABLE imap_sync (folder TEXT PRIMARY KEY, uidvalidity INTEGER DEFAULT 0, uid_next INTEGER DEFAULT 0);"#,
408407
()
409408
)
410409
.await?;
411-
for c in &[
412-
ConfiguredInboxFolder,
413-
ConfiguredSentboxFolder,
414-
ConfiguredMvboxFolder,
410+
for c in [
411+
"configured_inbox_folder",
412+
"configured_sentbox_folder",
413+
"configured_mvbox_folder",
415414
] {
416-
if let Some(folder) = context.get_config(*c).await? {
415+
if let Some(folder) = context.sql.get_raw_config(c).await? {
417416
let (uid_validity, last_seen_uid) =
418417
imap::get_config_last_seen_uid(context, &folder).await?;
419418
if last_seen_uid > 0 {

0 commit comments

Comments
 (0)