remove sentbox_move (#3111)

* remove SentboxMove

* adapt python test to removed sendbox_move option

* update CHANGELOG
This commit is contained in:
bjoern
2022-03-08 11:29:45 +01:00
committed by GitHub
parent a06e8677ac
commit 500e2d62a0
5 changed files with 16 additions and 78 deletions

View File

@@ -10,6 +10,8 @@
- add more SMTP logging #3093 - add more SMTP logging #3093
- place common headers like `From:` before the large `Autocrypt:` header #3079 - place common headers like `From:` before the large `Autocrypt:` header #3079
- keep track of securejoin joiner status in database to survive restarts #2920 - keep track of securejoin joiner status in database to survive restarts #2920
- remove never used `SentboxMove` option #3111
## 1.76.0 ## 1.76.0

View File

@@ -2732,7 +2732,6 @@ class TestOnlineAccount:
assert ac.get_config("configured_mvbox_folder") assert ac.get_config("configured_mvbox_folder")
ac1 = acfactory.get_online_configuring_account(move=mvbox_move) ac1 = acfactory.get_online_configuring_account(move=mvbox_move)
ac1.set_config("sentbox_move", "1")
ac2 = acfactory.get_online_configuring_account() ac2 = acfactory.get_online_configuring_account()
acfactory.wait_configure(ac1) acfactory.wait_configure(ac1)
@@ -2752,7 +2751,7 @@ class TestOnlineAccount:
if mvbox_move: if mvbox_move:
ac1.direct_imap.select_config_folder("mvbox") ac1.direct_imap.select_config_folder("mvbox")
else: else:
ac1.direct_imap.select_config_folder("sentbox") ac1.direct_imap.select_folder("INBOX")
ac1.direct_imap.idle_start() ac1.direct_imap.idle_start()
lp.sec("send out message with bcc to ourselves") lp.sec("send out message with bcc to ourselves")

View File

@@ -71,9 +71,6 @@ pub enum Config {
#[strum(props(default = "1"))] #[strum(props(default = "1"))]
MvboxMove, MvboxMove,
#[strum(props(default = "0"))]
SentboxMove, // If `MvboxMove` is true, this config is ignored. Currently only used in tests.
/// Watch for new messages in the "Mvbox" (aka DeltaChat folder) only. /// Watch for new messages in the "Mvbox" (aka DeltaChat folder) only.
/// ///
/// This will not entirely disable other folders, e.g. the spam folder will also still /// This will not entirely disable other folders, e.g. the spam folder will also still

View File

@@ -354,7 +354,6 @@ impl Context {
let sentbox_watch = self.get_config_int(Config::SentboxWatch).await?; let sentbox_watch = self.get_config_int(Config::SentboxWatch).await?;
let mvbox_move = self.get_config_int(Config::MvboxMove).await?; let mvbox_move = self.get_config_int(Config::MvboxMove).await?;
let sentbox_move = self.get_config_int(Config::SentboxMove).await?;
let only_fetch_mvbox = self.get_config_int(Config::OnlyFetchMvbox).await?; let only_fetch_mvbox = self.get_config_int(Config::OnlyFetchMvbox).await?;
let folders_configured = self let folders_configured = self
.sql .sql
@@ -419,7 +418,6 @@ impl Context {
); );
res.insert("sentbox_watch", sentbox_watch.to_string()); res.insert("sentbox_watch", sentbox_watch.to_string());
res.insert("mvbox_move", mvbox_move.to_string()); res.insert("mvbox_move", mvbox_move.to_string());
res.insert("sentbox_move", sentbox_move.to_string());
res.insert("only_fetch_mvbox", only_fetch_mvbox.to_string()); res.insert("only_fetch_mvbox", only_fetch_mvbox.to_string());
res.insert("folders_configured", folders_configured.to_string()); res.insert("folders_configured", folders_configured.to_string());
res.insert("configured_sentbox_folder", configured_sentbox_folder); res.insert("configured_sentbox_folder", configured_sentbox_folder);

View File

@@ -1654,7 +1654,6 @@ async fn should_move_out_of_spam(
/// messages from the Spam folder, the message will be ignored. /// messages from the Spam folder, the message will be ignored.
async fn spam_target_folder( async fn spam_target_folder(
context: &Context, context: &Context,
folder: &str,
headers: &[mailparse::MailHeader<'_>], headers: &[mailparse::MailHeader<'_>],
) -> Result<Option<Config>> { ) -> Result<Option<Config>> {
if !should_move_out_of_spam(context, headers).await? { if !should_move_out_of_spam(context, headers).await? {
@@ -1667,8 +1666,6 @@ async fn spam_target_folder(
|| context.get_config_bool(Config::OnlyFetchMvbox).await? || context.get_config_bool(Config::OnlyFetchMvbox).await?
{ {
Ok(Some(Config::ConfiguredMvboxFolder)) Ok(Some(Config::ConfiguredMvboxFolder))
} else if needs_move_to_sentbox(context, folder, headers).await? {
Ok(Some(Config::ConfiguredSentboxFolder))
} else { } else {
Ok(Some(Config::ConfiguredInboxFolder)) Ok(Some(Config::ConfiguredInboxFolder))
} }
@@ -1686,11 +1683,9 @@ pub async fn target_folder(
} }
if context.is_spam_folder(folder).await? { if context.is_spam_folder(folder).await? {
spam_target_folder(context, folder, headers).await spam_target_folder(context, headers).await
} else if needs_move_to_mvbox(context, headers).await? { } else if needs_move_to_mvbox(context, headers).await? {
Ok(Some(Config::ConfiguredMvboxFolder)) Ok(Some(Config::ConfiguredMvboxFolder))
} else if needs_move_to_sentbox(context, folder, headers).await? {
Ok(Some(Config::ConfiguredSentboxFolder))
} else { } else {
Ok(None) Ok(None)
} }
@@ -1725,44 +1720,6 @@ async fn needs_move_to_mvbox(
} }
} }
async fn prefetch_is_outgoing(
context: &Context,
headers: &[mailparse::MailHeader<'_>],
) -> Result<bool> {
let from_address_list = &mimeparser::get_from(headers);
// Only looking at the first address in the `From:` field.
if let Some(info) = from_address_list.first() {
if context.is_self_addr(&info.addr).await? {
Ok(true)
} else {
Ok(false)
}
} else {
Ok(false)
}
}
async fn needs_move_to_sentbox(
context: &Context,
folder: &str,
headers: &[mailparse::MailHeader<'_>],
) -> Result<bool> {
let needs_move = context.get_config_bool(Config::SentboxMove).await?
&& context
.get_config(Config::ConfiguredSentboxFolder)
.await?
.is_some()
&& context.is_inbox(folder).await?
&& headers.get_header_value(HeaderDef::ChatVersion).is_some()
&& headers
.get_header_value(HeaderDef::AutocryptSetupMessage)
.is_none()
&& prefetch_is_outgoing(context, headers).await?;
Ok(needs_move)
}
/// Try to get the folder meaning by the name of the folder only used if the server does not support XLIST. /// Try to get the folder meaning by the name of the folder only used if the server does not support XLIST.
// TODO: lots languages missing - maybe there is a list somewhere on other MUAs? // TODO: lots languages missing - maybe there is a list somewhere on other MUAs?
// however, if we fail to find out the sent-folder, // however, if we fail to find out the sent-folder,
@@ -2330,7 +2287,6 @@ mod tests {
accepted_chat: bool, accepted_chat: bool,
outgoing: bool, outgoing: bool,
setupmessage: bool, setupmessage: bool,
sentbox_move: bool,
) -> Result<()> { ) -> Result<()> {
println!("Testing: For folder {}, mvbox_move {}, chat_msg {}, accepted {}, outgoing {}, setupmessage {}", println!("Testing: For folder {}, mvbox_move {}, chat_msg {}, accepted {}, outgoing {}, setupmessage {}",
folder, mvbox_move, chat_msg, accepted_chat, outgoing, setupmessage); folder, mvbox_move, chat_msg, accepted_chat, outgoing, setupmessage);
@@ -2349,9 +2305,6 @@ mod tests {
.set_config(Config::MvboxMove, Some(if mvbox_move { "1" } else { "0" })) .set_config(Config::MvboxMove, Some(if mvbox_move { "1" } else { "0" }))
.await?; .await?;
t.ctx.set_config(Config::ShowEmails, Some("2")).await?; t.ctx.set_config(Config::ShowEmails, Some("2")).await?;
t.ctx
.set_config_bool(Config::SentboxMove, sentbox_move)
.await?;
if accepted_chat { if accepted_chat {
let contact_id = Contact::create(&t.ctx, "", "bob@example.net").await?; let contact_id = Contact::create(&t.ctx, "", "bob@example.net").await?;
@@ -2443,7 +2396,6 @@ mod tests {
true, true,
false, false,
false, false,
false,
) )
.await?; .await?;
} }
@@ -2461,7 +2413,6 @@ mod tests {
false, false,
false, false,
false, false,
false,
) )
.await?; .await?;
} }
@@ -2470,26 +2421,18 @@ mod tests {
#[async_std::test] #[async_std::test]
async fn test_target_folder_outgoing() -> Result<()> { async fn test_target_folder_outgoing() -> Result<()> {
for sentbox_move in &[true, false] { // Test outgoing emails
// Test outgoing emails for (folder, mvbox_move, chat_msg, expected_destination) in COMBINATIONS_ACCEPTED_CHAT {
for (folder, mvbox_move, chat_msg, mut expected_destination) in check_target_folder_combination(
COMBINATIONS_ACCEPTED_CHAT folder,
{ *mvbox_move,
if *folder == "INBOX" && !mvbox_move && *chat_msg && *sentbox_move { *chat_msg,
expected_destination = "Sent" expected_destination,
} true,
check_target_folder_combination( true,
folder, false,
*mvbox_move, )
*chat_msg, .await?;
expected_destination,
true,
true,
false,
*sentbox_move,
)
.await?;
}
} }
Ok(()) Ok(())
} }
@@ -2506,7 +2449,6 @@ mod tests {
false, false,
true, true,
true, true,
false,
) )
.await?; .await?;
} }