Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion python/src/deltachat/testplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ def prepare_account_from_liveconfig(self, configdict) -> Account:
assert "addr" in configdict and "mail_pw" in configdict, configdict
configdict.setdefault("bcc_self", False)
configdict.setdefault("mvbox_move", False)
configdict.setdefault("sentbox_watch", False)
configdict.setdefault("sync_msgs", False)
configdict.setdefault("delete_server_after", 0)
ac.update_config(configdict)
Expand Down
54 changes: 20 additions & 34 deletions python/tests/test_1_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,26 +269,28 @@ def test_enable_mvbox_move(acfactory, lp):
assert ac2._evtracker.wait_next_incoming_message().text == "message1"


def test_mvbox_sentbox_threads(acfactory, lp):
def test_mvbox_thread_and_trash(acfactory, lp):
lp.sec("ac1: start with mvbox thread")
ac1 = acfactory.new_online_configuring_account(mvbox_move=True, sentbox_watch=False)
ac1 = acfactory.new_online_configuring_account(mvbox_move=True)

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

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

lp.sec("ac1: create and configure sentbox")
ac1.direct_imap.create_folder("Sent")
ac1.set_config("sentbox_watch", "1")
lp.sec("ac1: create trash")
ac1.direct_imap.create_folder("Trash")
ac1.set_config("scan_all_folders_debounce_secs", "0")
ac1.stop_io()
ac1.start_io()

lp.sec("ac1: send message and wait for ac2 to receive it")
acfactory.get_accepted_chat(ac1, ac2).send_text("message1")
assert ac2._evtracker.wait_next_incoming_message().text == "message1"

assert ac1.get_config("configured_mvbox_folder") == "DeltaChat"
while ac1.get_config("configured_sentbox_folder") != "Sent":
while ac1.get_config("configured_trash_folder") != "Trash":
ac1._evtracker.get_matching("DC_EVENT_CONNECTIVITY_CHANGED")


Expand Down Expand Up @@ -832,9 +834,9 @@ def test_no_draft_if_cant_send(acfactory):

def test_dont_show_emails(acfactory, lp):
"""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.
So: If it's outgoing AND there is no Received header, then ignore the email.

If the draft email is sent out later (i.e. moved to "Sent"), it must be shown.
If the draft email is sent out and received later (i.e. it's in "Inbox"), it must be shown.

Also, test that unknown emails in the Spam folder are not shown."""
ac1 = acfactory.new_online_configuring_account()
Expand All @@ -843,7 +845,6 @@ def test_dont_show_emails(acfactory, lp):

acfactory.wait_configured(ac1)
ac1.direct_imap.create_folder("Drafts")
ac1.direct_imap.create_folder("Sent")
ac1.direct_imap.create_folder("Spam")
ac1.direct_imap.create_folder("Junk")

Expand All @@ -859,21 +860,7 @@ def test_dont_show_emails(acfactory, lp):
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

message in Drafts that is moved to Sent later
""".format(
ac1.get_config("configured_addr"),
),
)
ac1.direct_imap.append(
"Sent",
"""
From: ac1 <{}>
Subject: subj
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

message in Sent
message in Drafts received later
""".format(
ac1.get_config("configured_addr"),
),
Expand Down Expand Up @@ -953,31 +940,30 @@ def test_dont_show_emails(acfactory, lp):
lp.sec("All prepared, now let DC find the message")
ac1.start_io()

msg = ac1._evtracker.wait_next_messages_changed()

# Wait until each folder was scanned, this is necessary for this test to test what it should test:
ac1._evtracker.wait_idle_inbox_ready()

assert msg.text == "subj – message in Sent"
fresh_msgs = list(ac1.get_fresh_messages())
msg = fresh_msgs[0]
chat_msgs = msg.chat.get_messages()
assert len(chat_msgs) == 2
assert len(chat_msgs) == 1
assert any(msg.text == "subj – Actually interesting message in Spam" for msg in chat_msgs)

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

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

ac1.start_io()
msg2 = ac1._evtracker.wait_next_messages_changed()

assert msg2.text == "subj – message in Drafts that is moved to Sent later"
assert len(msg.chat.get_messages()) == 3
assert msg2.text == "subj – message in Drafts received later"
assert len(msg.chat.get_messages()) == 2


def test_bot(acfactory, lp):
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-provider-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -euo pipefail
export TZ=UTC

# Provider database revision.
REV=1cce91c1f1065b47e4f307d6fe2f4cca68c74d2e
REV=d041136c19a48b493823b46d472f12b9ee94ae80

CORE_ROOT="$PWD"
TMP="$(mktemp -d)"
Expand Down
28 changes: 2 additions & 26 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ pub enum Config {
#[strum(props(default = "1"))]
MdnsEnabled,

/// True if "Sent" folder should be watched for changes.
#[strum(props(default = "0"))]
SentboxWatch,

/// True if chat messages should be moved to a separate folder. Auto-sent messages like sync
/// ones are moved there anyway.
#[strum(props(default = "1"))]
Expand Down Expand Up @@ -285,9 +281,6 @@ pub enum Config {
/// Configured folder for chat messages.
ConfiguredMvboxFolder,

/// Configured "Sent" folder.
ConfiguredSentboxFolder,

/// Configured "Trash" folder.
ConfiguredTrashFolder,

Expand Down Expand Up @@ -476,10 +469,7 @@ impl Config {

/// Whether the config option needs an IO scheduler restart to take effect.
pub(crate) fn needs_io_restart(&self) -> bool {
matches!(
self,
Config::MvboxMove | Config::OnlyFetchMvbox | Config::SentboxWatch
)
matches!(self, Config::MvboxMove | Config::OnlyFetchMvbox)
}
}

Expand Down Expand Up @@ -605,15 +595,6 @@ impl Context {
|| !self.get_config_bool(Config::IsChatmail).await?)
}

/// Returns true if sentbox ("Sent" folder) should be watched.
pub(crate) async fn should_watch_sentbox(&self) -> Result<bool> {
Ok(self.get_config_bool(Config::SentboxWatch).await?
&& self
.get_config(Config::ConfiguredSentboxFolder)
.await?
.is_some())
}

/// Returns true if sync messages should be sent.
pub(crate) async fn should_send_sync_msgs(&self) -> Result<bool> {
Ok(self.get_config_bool(Config::SyncMsgs).await?
Expand Down Expand Up @@ -702,7 +683,6 @@ impl Context {
| Config::ProxyEnabled
| Config::BccSelf
| Config::MdnsEnabled
| Config::SentboxWatch
| Config::MvboxMove
| Config::OnlyFetchMvbox
| Config::DeleteToTrash
Expand Down Expand Up @@ -732,11 +712,7 @@ impl Context {
true => self.scheduler.pause(self).await?,
_ => Default::default(),
};
self.set_config_internal(key, value).await?;
if key == Config::SentboxWatch {
self.last_full_folder_scan.lock().await.take();
}
Ok(())
self.set_config_internal(key, value).await
}

pub(crate) async fn set_config_internal(&self, key: Config, value: Option<&str>) -> Result<()> {
Expand Down
1 change: 0 additions & 1 deletion src/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ async fn configure(ctx: &Context, param: &EnteredLoginParam) -> Result<Option<&'
true => ctx.get_config_bool(Config::IsChatmail).await?,
};
if is_chatmail {
ctx.set_config(Config::SentboxWatch, None).await?;
ctx.set_config(Config::MvboxMove, Some("0")).await?;
ctx.set_config(Config::OnlyFetchMvbox, None).await?;
ctx.set_config(Config::ShowEmails, None).await?;
Expand Down
13 changes: 0 additions & 13 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,6 @@ impl Context {
Err(err) => format!("<key failure: {err}>"),
};

let sentbox_watch = self.get_config_int(Config::SentboxWatch).await?;
let mvbox_move = self.get_config_int(Config::MvboxMove).await?;
let only_fetch_mvbox = self.get_config_int(Config::OnlyFetchMvbox).await?;
let folders_configured = self
Expand All @@ -862,10 +861,6 @@ impl Context {
.get_config(Config::ConfiguredInboxFolder)
.await?
.unwrap_or_else(|| "<unset>".to_string());
let configured_sentbox_folder = self
.get_config(Config::ConfiguredSentboxFolder)
.await?
.unwrap_or_else(|| "<unset>".to_string());
let configured_mvbox_folder = self
.get_config(Config::ConfiguredMvboxFolder)
.await?
Expand Down Expand Up @@ -954,15 +949,13 @@ impl Context {
.await?
.to_string(),
);
res.insert("sentbox_watch", sentbox_watch.to_string());
res.insert("mvbox_move", mvbox_move.to_string());
res.insert("only_fetch_mvbox", only_fetch_mvbox.to_string());
res.insert(
constants::DC_FOLDERS_CONFIGURED_KEY,
folders_configured.to_string(),
);
res.insert("configured_inbox_folder", configured_inbox_folder);
res.insert("configured_sentbox_folder", configured_sentbox_folder);
res.insert("configured_mvbox_folder", configured_mvbox_folder);
res.insert("configured_trash_folder", configured_trash_folder);
res.insert("mdns_enabled", mdns_enabled.to_string());
Expand Down Expand Up @@ -1428,12 +1421,6 @@ impl Context {
Ok(inbox.as_deref() == Some(folder_name))
}

/// Returns true if given folder name is the name of the "sent" folder.
pub async fn is_sentbox(&self, folder_name: &str) -> Result<bool> {
let sentbox = self.get_config(Config::ConfiguredSentboxFolder).await?;
Ok(sentbox.as_deref() == Some(folder_name))
}

/// Returns true if given folder name is the name of the "DeltaChat" folder.
pub async fn is_mvbox(&self, folder_name: &str) -> Result<bool> {
let mvbox = self.get_config(Config::ConfiguredMvboxFolder).await?;
Expand Down
50 changes: 3 additions & 47 deletions src/imap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ pub enum FolderMeaning {
Spam,
Inbox,
Mvbox,
Sent,
Trash,
Drafts,

Expand All @@ -164,7 +163,6 @@ impl FolderMeaning {
FolderMeaning::Spam => None,
FolderMeaning::Inbox => Some(Config::ConfiguredInboxFolder),
FolderMeaning::Mvbox => Some(Config::ConfiguredMvboxFolder),
FolderMeaning::Sent => Some(Config::ConfiguredSentboxFolder),
FolderMeaning::Trash => Some(Config::ConfiguredTrashFolder),
FolderMeaning::Drafts => None,
FolderMeaning::Virtual => None,
Expand Down Expand Up @@ -790,9 +788,6 @@ impl Imap {
context: &Context,
session: &mut Session,
) -> Result<()> {
add_all_recipients_as_contacts(context, session, Config::ConfiguredSentboxFolder)
.await
.context("failed to get recipients from the sentbox")?;
add_all_recipients_as_contacts(context, session, Config::ConfiguredMvboxFolder)
.await
.context("failed to get recipients from the movebox")?;
Expand Down Expand Up @@ -1971,7 +1966,7 @@ async fn spam_target_folder_cfg(

if needs_move_to_mvbox(context, headers).await?
// If OnlyFetchMvbox is set, we don't want to move the message to
// the inbox or sentbox where we wouldn't fetch it again:
// the inbox where we wouldn't fetch it again:
|| context.get_config_bool(Config::OnlyFetchMvbox).await?
{
Ok(Some(Config::ConfiguredMvboxFolder))
Expand All @@ -1980,7 +1975,7 @@ async fn spam_target_folder_cfg(
}
}

/// Returns `ConfiguredInboxFolder`, `ConfiguredMvboxFolder` or `ConfiguredSentboxFolder` if
/// Returns `ConfiguredInboxFolder` or `ConfiguredMvboxFolder` if
/// the message needs to be moved from `folder`. Otherwise returns `None`.
pub async fn target_folder_cfg(
context: &Context,
Expand Down Expand Up @@ -2067,38 +2062,6 @@ async fn needs_move_to_mvbox(
// but sth. different in others - a hard job.
fn get_folder_meaning_by_name(folder_name: &str) -> FolderMeaning {
// source: <https://stackoverflow.com/questions/2185391/localized-gmail-imap-folders>
const SENT_NAMES: &[&str] = &[
"sent",
"sentmail",
"sent objects",
"gesendet",
"Sent Mail",
"Sendte e-mails",
"Enviados",
"Messages envoyés",
"Messages envoyes",
"Posta inviata",
"Verzonden berichten",
"Wyslane",
"E-mails enviados",
"Correio enviado",
"Enviada",
"Enviado",
"Gönderildi",
"Inviati",
"Odeslaná pošta",
"Sendt",
"Skickat",
"Verzonden",
"Wysłane",
"Éléments envoyés",
"Απεσταλμένα",
"Отправленные",
"寄件備份",
"已发送邮件",
"送信済み",
"보낸편지함",
];
const SPAM_NAMES: &[&str] = &[
"spam",
"junk",
Expand Down Expand Up @@ -2163,9 +2126,7 @@ fn get_folder_meaning_by_name(folder_name: &str) -> FolderMeaning {
];
let lower = folder_name.to_lowercase();

if SENT_NAMES.iter().any(|s| s.to_lowercase() == lower) {
FolderMeaning::Sent
} else if SPAM_NAMES.iter().any(|s| s.to_lowercase() == lower) {
if SPAM_NAMES.iter().any(|s| s.to_lowercase() == lower) {
FolderMeaning::Spam
} else if DRAFT_NAMES.iter().any(|s| s.to_lowercase() == lower) {
FolderMeaning::Drafts
Expand All @@ -2180,7 +2141,6 @@ fn get_folder_meaning_by_attrs(folder_attrs: &[NameAttribute]) -> FolderMeaning
for attr in folder_attrs {
match attr {
NameAttribute::Trash => return FolderMeaning::Trash,
NameAttribute::Sent => return FolderMeaning::Sent,
NameAttribute::Junk => return FolderMeaning::Spam,
NameAttribute::Drafts => return FolderMeaning::Drafts,
NameAttribute::All | NameAttribute::Flagged => return FolderMeaning::Virtual,
Expand Down Expand Up @@ -2524,10 +2484,6 @@ async fn should_ignore_folder(
if !context.get_config_bool(Config::OnlyFetchMvbox).await? {
return Ok(false);
}
if context.is_sentbox(folder).await? {
// Still respect the SentboxWatch setting.
return Ok(!context.get_config_bool(Config::SentboxWatch).await?);
}
Ok(!(context.is_mvbox(folder).await? || folder_meaning == FolderMeaning::Spam))
}

Expand Down
Loading
Loading