Skip to content

Commit 4cf89fd

Browse files
committed
feat: Remove Config::SentboxWatch (#7178)
The motivation is to reduce code complexity, get rid of the extra IMAP connection and cases when messages are added to chats by Inbox and Sentbox loops in parallel which leads to various message sorting bugs, particularly to outgoing messages breaking sorting of incoming ones which are fetched later, but may have a smaller "Date".
1 parent b9ff40c commit 4cf89fd

File tree

13 files changed

+35
-95
lines changed

13 files changed

+35
-95
lines changed

python/src/deltachat/testplugin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ def prepare_account_from_liveconfig(self, configdict) -> Account:
523523
assert "addr" in configdict and "mail_pw" in configdict, configdict
524524
configdict.setdefault("bcc_self", False)
525525
configdict.setdefault("mvbox_move", False)
526-
configdict.setdefault("sentbox_watch", False)
527526
configdict.setdefault("sync_msgs", False)
528527
configdict.setdefault("delete_server_after", 0)
529528
ac.update_config(configdict)

python/tests/test_1_online.py

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

271271

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

276-
lp.sec("ac2: start without mvbox/sentbox threads")
277-
ac2 = acfactory.new_online_configuring_account(mvbox_move=False, sentbox_watch=False)
276+
lp.sec("ac2: start without a mvbox thread")
277+
ac2 = acfactory.new_online_configuring_account(mvbox_move=False)
278278

279279
lp.sec("ac2 and ac1: waiting for configuration")
280280
acfactory.bring_accounts_online()
281281

282-
lp.sec("ac1: create and configure sentbox")
282+
lp.sec("ac1: create sentbox")
283283
ac1.direct_imap.create_folder("Sent")
284-
ac1.set_config("sentbox_watch", "1")
284+
ac1.set_config("scan_all_folders_debounce_secs", "0")
285+
ac1.stop_io()
286+
ac1.start_io()
285287

286288
lp.sec("ac1: send message and wait for ac2 to receive it")
287289
acfactory.get_accepted_chat(ac1, ac2).send_text("message1")

scripts/update-provider-database.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -euo pipefail
66
export TZ=UTC
77

88
# Provider database revision.
9-
REV=1cce91c1f1065b47e4f307d6fe2f4cca68c74d2e
9+
REV=d041136c19a48b493823b46d472f12b9ee94ae80
1010

1111
CORE_ROOT="$PWD"
1212
TMP="$(mktemp -d)"

src/config.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ pub enum Config {
156156
#[strum(props(default = "1"))]
157157
MdnsEnabled,
158158

159-
/// True if "Sent" folder should be watched for changes.
160-
#[strum(props(default = "0"))]
161-
SentboxWatch,
162-
163159
/// True if chat messages should be moved to a separate folder. Auto-sent messages like sync
164160
/// ones are moved there anyway.
165161
#[strum(props(default = "1"))]
@@ -476,10 +472,7 @@ impl Config {
476472

477473
/// Whether the config option needs an IO scheduler restart to take effect.
478474
pub(crate) fn needs_io_restart(&self) -> bool {
479-
matches!(
480-
self,
481-
Config::MvboxMove | Config::OnlyFetchMvbox | Config::SentboxWatch
482-
)
475+
matches!(self, Config::MvboxMove | Config::OnlyFetchMvbox)
483476
}
484477
}
485478

@@ -605,15 +598,6 @@ impl Context {
605598
|| !self.get_config_bool(Config::IsChatmail).await?)
606599
}
607600

608-
/// Returns true if sentbox ("Sent" folder) should be watched.
609-
pub(crate) async fn should_watch_sentbox(&self) -> Result<bool> {
610-
Ok(self.get_config_bool(Config::SentboxWatch).await?
611-
&& self
612-
.get_config(Config::ConfiguredSentboxFolder)
613-
.await?
614-
.is_some())
615-
}
616-
617601
/// Returns true if sync messages should be sent.
618602
pub(crate) async fn should_send_sync_msgs(&self) -> Result<bool> {
619603
Ok(self.get_config_bool(Config::SyncMsgs).await?
@@ -702,7 +686,6 @@ impl Context {
702686
| Config::ProxyEnabled
703687
| Config::BccSelf
704688
| Config::MdnsEnabled
705-
| Config::SentboxWatch
706689
| Config::MvboxMove
707690
| Config::OnlyFetchMvbox
708691
| Config::DeleteToTrash
@@ -732,11 +715,7 @@ impl Context {
732715
true => self.scheduler.pause(self).await?,
733716
_ => Default::default(),
734717
};
735-
self.set_config_internal(key, value).await?;
736-
if key == Config::SentboxWatch {
737-
self.last_full_folder_scan.lock().await.take();
738-
}
739-
Ok(())
718+
self.set_config_internal(key, value).await
740719
}
741720

742721
pub(crate) async fn set_config_internal(&self, key: Config, value: Option<&str>) -> Result<()> {

src/configure.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ async fn configure(ctx: &Context, param: &EnteredLoginParam) -> Result<Option<&'
555555
true => ctx.get_config_bool(Config::IsChatmail).await?,
556556
};
557557
if is_chatmail {
558-
ctx.set_config(Config::SentboxWatch, None).await?;
559558
ctx.set_config(Config::MvboxMove, Some("0")).await?;
560559
ctx.set_config(Config::OnlyFetchMvbox, None).await?;
561560
ctx.set_config(Config::ShowEmails, None).await?;

src/context.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,6 @@ impl Context {
849849
Err(err) => format!("<key failure: {err}>"),
850850
};
851851

852-
let sentbox_watch = self.get_config_int(Config::SentboxWatch).await?;
853852
let mvbox_move = self.get_config_int(Config::MvboxMove).await?;
854853
let only_fetch_mvbox = self.get_config_int(Config::OnlyFetchMvbox).await?;
855854
let folders_configured = self
@@ -954,7 +953,6 @@ impl Context {
954953
.await?
955954
.to_string(),
956955
);
957-
res.insert("sentbox_watch", sentbox_watch.to_string());
958956
res.insert("mvbox_move", mvbox_move.to_string());
959957
res.insert("only_fetch_mvbox", only_fetch_mvbox.to_string());
960958
res.insert(
@@ -1428,12 +1426,6 @@ impl Context {
14281426
Ok(inbox.as_deref() == Some(folder_name))
14291427
}
14301428

1431-
/// Returns true if given folder name is the name of the "sent" folder.
1432-
pub async fn is_sentbox(&self, folder_name: &str) -> Result<bool> {
1433-
let sentbox = self.get_config(Config::ConfiguredSentboxFolder).await?;
1434-
Ok(sentbox.as_deref() == Some(folder_name))
1435-
}
1436-
14371429
/// Returns true if given folder name is the name of the "DeltaChat" folder.
14381430
pub async fn is_mvbox(&self, folder_name: &str) -> Result<bool> {
14391431
let mvbox = self.get_config(Config::ConfiguredMvboxFolder).await?;

src/imap.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ async fn spam_target_folder_cfg(
19711971

19721972
if needs_move_to_mvbox(context, headers).await?
19731973
// If OnlyFetchMvbox is set, we don't want to move the message to
1974-
// the inbox or sentbox where we wouldn't fetch it again:
1974+
// the inbox where we wouldn't fetch it again:
19751975
|| context.get_config_bool(Config::OnlyFetchMvbox).await?
19761976
{
19771977
Ok(Some(Config::ConfiguredMvboxFolder))
@@ -2524,10 +2524,6 @@ async fn should_ignore_folder(
25242524
if !context.get_config_bool(Config::OnlyFetchMvbox).await? {
25252525
return Ok(false);
25262526
}
2527-
if context.is_sentbox(folder).await? {
2528-
// Still respect the SentboxWatch setting.
2529-
return Ok(!context.get_config_bool(Config::SentboxWatch).await?);
2530-
}
25312527
Ok(!(context.is_mvbox(folder).await? || folder_meaning == FolderMeaning::Spam))
25322528
}
25332529

src/imap/imap_tests.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ const COMBINATIONS_ACCEPTED_CHAT: &[(&str, bool, bool, &str)] = &[
183183
("INBOX", false, true, "INBOX"),
184184
("INBOX", true, false, "INBOX"),
185185
("INBOX", true, true, "DeltaChat"),
186-
("Sent", false, false, "Sent"),
187-
("Sent", false, true, "Sent"),
188-
("Sent", true, false, "Sent"),
189-
("Sent", true, true, "DeltaChat"),
190186
("Spam", false, false, "INBOX"), // Move classical emails in accepted chats from Spam to Inbox, not 100% sure on this, we could also just never move non-chat-msgs
191187
("Spam", false, true, "INBOX"),
192188
("Spam", true, false, "INBOX"), // Move classical emails in accepted chats from Spam to Inbox, not 100% sure on this, we could also just never move non-chat-msgs
@@ -199,10 +195,6 @@ const COMBINATIONS_REQUEST: &[(&str, bool, bool, &str)] = &[
199195
("INBOX", false, true, "INBOX"),
200196
("INBOX", true, false, "INBOX"),
201197
("INBOX", true, true, "DeltaChat"),
202-
("Sent", false, false, "Sent"),
203-
("Sent", false, true, "Sent"),
204-
("Sent", true, false, "Sent"),
205-
("Sent", true, true, "DeltaChat"),
206198
("Spam", false, false, "Spam"),
207199
("Spam", false, true, "INBOX"),
208200
("Spam", true, false, "Spam"),

src/imap/scan_folders.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ impl Imap {
108108

109109
pub(crate) async fn get_watched_folder_configs(context: &Context) -> Result<Vec<Config>> {
110110
let mut res = vec![Config::ConfiguredInboxFolder];
111-
if context.get_config_bool(Config::SentboxWatch).await? {
112-
res.push(Config::ConfiguredSentboxFolder);
113-
}
114111
if context.should_watch_mvbox().await? {
115112
res.push(Config::ConfiguredMvboxFolder);
116113
}

src/provider/data.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,6 @@ static P_FIVE_CHAT: Provider = Provider {
510510
key: Config::BccSelf,
511511
value: "1",
512512
},
513-
ConfigDefault {
514-
key: Config::SentboxWatch,
515-
value: "0",
516-
},
517513
ConfigDefault {
518514
key: Config::MvboxMove,
519515
value: "0",
@@ -1084,10 +1080,6 @@ static P_NAUTA_CU: Provider = Provider {
10841080
key: Config::DeleteServerAfter,
10851081
value: "1",
10861082
},
1087-
ConfigDefault {
1088-
key: Config::SentboxWatch,
1089-
value: "0",
1090-
},
10911083
ConfigDefault {
10921084
key: Config::MvboxMove,
10931085
value: "0",
@@ -1629,10 +1621,6 @@ static P_TESTRUN: Provider = Provider {
16291621
key: Config::BccSelf,
16301622
value: "1",
16311623
},
1632-
ConfigDefault {
1633-
key: Config::SentboxWatch,
1634-
value: "0",
1635-
},
16361624
ConfigDefault {
16371625
key: Config::MvboxMove,
16381626
value: "0",
@@ -1898,11 +1886,11 @@ static P_WKPB_DE: Provider = Provider {
18981886
oauth2_authorizer: None,
18991887
};
19001888

1901-
// yahoo.md: yahoo.com, yahoo.de, yahoo.it, yahoo.fr, yahoo.es, yahoo.se, yahoo.co.uk, yahoo.co.nz, yahoo.com.au, yahoo.com.ar, yahoo.com.br, yahoo.com.mx, ymail.com, rocketmail.com, yahoodns.net
1889+
// yahoo.md: yahoo.com, yahoo.de, yahoo.it, yahoo.fr, yahoo.es, yahoo.se, yahoo.co.uk, yahoo.co.nz, yahoo.com.au, yahoo.com.ar, yahoo.com.br, yahoo.com.mx, myyahoo.com, ymail.com, rocketmail.com, yahoodns.net
19021890
static P_YAHOO: Provider = Provider {
19031891
id: "yahoo",
19041892
status: Status::Preparation,
1905-
before_login_hint: "To use your Yahoo email address you have to create an \"App-Password\" in the account security screen.",
1893+
before_login_hint: "To use your Yahoo email address you have to create an app password in the Yahoo account security screen.",
19061894
after_login_hint: "",
19071895
overview_page: "https://providers.delta.chat/yahoo",
19081896
server: &[
@@ -2041,7 +2029,7 @@ static P_ZOHO: Provider = Provider {
20412029
oauth2_authorizer: None,
20422030
};
20432031

2044-
pub(crate) static PROVIDER_DATA: [(&str, &Provider); 533] = [
2032+
pub(crate) static PROVIDER_DATA: [(&str, &Provider); 534] = [
20452033
("163.com", &P_163),
20462034
("aktivix.org", &P_AKTIVIX_ORG),
20472035
("aliyun.com", &P_ALIYUN),
@@ -2560,6 +2548,7 @@ pub(crate) static PROVIDER_DATA: [(&str, &Provider); 533] = [
25602548
("yahoo.com.ar", &P_YAHOO),
25612549
("yahoo.com.br", &P_YAHOO),
25622550
("yahoo.com.mx", &P_YAHOO),
2551+
("myyahoo.com", &P_YAHOO),
25632552
("ymail.com", &P_YAHOO),
25642553
("rocketmail.com", &P_YAHOO),
25652554
("yahoodns.net", &P_YAHOO),
@@ -2658,4 +2647,4 @@ pub(crate) static PROVIDER_IDS: LazyLock<HashMap<&'static str, &'static Provider
26582647
});
26592648

26602649
pub static _PROVIDER_UPDATED: LazyLock<chrono::NaiveDate> =
2661-
LazyLock::new(|| chrono::NaiveDate::from_ymd_opt(2025, 9, 4).unwrap());
2650+
LazyLock::new(|| chrono::NaiveDate::from_ymd_opt(2025, 9, 10).unwrap());

0 commit comments

Comments
 (0)