mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46:30 +03:00
Compare commits
3 Commits
v2.39.0
...
iequidoo/a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c95336c89 | ||
|
|
1cf067c045 | ||
|
|
275630d7c3 |
@@ -1776,7 +1776,7 @@ def test_group_quote(acfactory, lp):
|
||||
"xyz",
|
||||
False,
|
||||
"xyz",
|
||||
), # Test that emails aren't found in a random folder
|
||||
), # Test that emails are recognized in a random folder but not moved
|
||||
(
|
||||
"xyz",
|
||||
True,
|
||||
@@ -1806,7 +1806,7 @@ def test_scan_folders(acfactory, lp, folder, move, expected_destination):
|
||||
ac1.stop_io()
|
||||
assert folder in ac1.direct_imap.list_folders()
|
||||
|
||||
lp.sec("Send a message to from ac2 to ac1 and manually move it to `folder`")
|
||||
lp.sec("Send a message to from ac2 to ac1 and manually move it to the mvbox")
|
||||
ac1.direct_imap.select_config_folder("inbox")
|
||||
with ac1.direct_imap.idle() as idle1:
|
||||
acfactory.get_accepted_chat(ac2, ac1).send_text("hello")
|
||||
@@ -1816,17 +1816,10 @@ def test_scan_folders(acfactory, lp, folder, move, expected_destination):
|
||||
lp.sec("start_io() and see if DeltaChat finds the message (" + variant + ")")
|
||||
ac1.set_config("scan_all_folders_debounce_secs", "0")
|
||||
ac1.start_io()
|
||||
chat = ac1.create_chat(ac2)
|
||||
n_msgs = 1 # "Messages are end-to-end encrypted."
|
||||
if folder == "Spam":
|
||||
msg = ac1._evtracker.wait_next_incoming_message()
|
||||
assert msg.text == "hello"
|
||||
n_msgs += 1
|
||||
else:
|
||||
ac1._evtracker.wait_idle_inbox_ready()
|
||||
assert len(chat.get_messages()) == n_msgs
|
||||
msg = ac1._evtracker.wait_next_incoming_message()
|
||||
assert msg.text == "hello"
|
||||
|
||||
# The message has reached its destination.
|
||||
# The message has been downloaded, which means it has reached its destination.
|
||||
ac1.direct_imap.select_folder(expected_destination)
|
||||
assert len(ac1.direct_imap.get_all_messages()) == 1
|
||||
if folder != expected_destination:
|
||||
|
||||
@@ -165,11 +165,11 @@ pub enum Config {
|
||||
#[strum(props(default = "1"))]
|
||||
MvboxMove,
|
||||
|
||||
/// Watch for new messages in the "Mvbox" (aka DeltaChat folder) only.
|
||||
/// Only watch the mvbox (aka DeltaChat folder) and, if `MvboxMove` is set, Inbox.
|
||||
///
|
||||
/// This will not entirely disable other folders, e.g. the spam folder will also still
|
||||
/// be watched for new messages.
|
||||
#[strum(props(default = "0"))]
|
||||
/// be scanned for new messages.
|
||||
#[strum(props(default = "1"))]
|
||||
OnlyFetchMvbox,
|
||||
|
||||
/// Whether to show classic emails or only chat messages.
|
||||
|
||||
14
src/imap.rs
14
src/imap.rs
@@ -823,10 +823,7 @@ impl Session {
|
||||
.context("listing folders for resync")?;
|
||||
for folder in all_folders {
|
||||
let folder_meaning = get_folder_meaning(&folder);
|
||||
if !matches!(
|
||||
folder_meaning,
|
||||
FolderMeaning::Virtual | FolderMeaning::Unknown
|
||||
) {
|
||||
if folder_meaning != FolderMeaning::Virtual {
|
||||
self.resync_folder_uids(context, folder.name(), folder_meaning)
|
||||
.await?;
|
||||
}
|
||||
@@ -2044,9 +2041,9 @@ 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:
|
||||
|| context.get_config_bool(Config::OnlyFetchMvbox).await?
|
||||
// Don't move the message to Inbox if we won't fetch the message again there.
|
||||
|| (context.get_config_bool(Config::OnlyFetchMvbox).await?
|
||||
&& !context.get_config_bool(Config::MvboxMove).await?)
|
||||
{
|
||||
Ok(Some(Config::ConfiguredMvboxFolder))
|
||||
} else {
|
||||
@@ -2573,6 +2570,9 @@ async fn should_ignore_folder(
|
||||
// Still respect the SentboxWatch setting.
|
||||
return Ok(!context.get_config_bool(Config::SentboxWatch).await?);
|
||||
}
|
||||
if context.is_inbox(folder).await? {
|
||||
return Ok(!context.get_config_bool(Config::MvboxMove).await?);
|
||||
}
|
||||
Ok(!(context.is_mvbox(folder).await? || folder_meaning == FolderMeaning::Spam))
|
||||
}
|
||||
|
||||
|
||||
@@ -122,8 +122,9 @@ async fn check_target_folder_combination(
|
||||
t.ctx
|
||||
.set_config(Config::ConfiguredSentboxFolder, Some("Sent"))
|
||||
.await?;
|
||||
t.ctx.set_config_bool(Config::MvboxMove, mvbox_move).await?;
|
||||
t.ctx
|
||||
.set_config(Config::MvboxMove, Some(if mvbox_move { "1" } else { "0" }))
|
||||
.set_config_bool(Config::OnlyFetchMvbox, mvbox_move)
|
||||
.await?;
|
||||
|
||||
if accepted_chat {
|
||||
|
||||
@@ -71,10 +71,13 @@ impl Imap {
|
||||
_ => folder_meaning,
|
||||
};
|
||||
|
||||
// Don't scan folders that are watched anyway
|
||||
if !watched_folders.contains(&folder.name().to_string())
|
||||
// Inbox shouldn't be scanned, getting messages from Inbox delayed doesn't make
|
||||
// sense, the user should enable watching it instead.
|
||||
&& folder_meaning != FolderMeaning::Inbox
|
||||
&& folder_meaning != FolderMeaning::Trash
|
||||
&& folder_meaning != FolderMeaning::Unknown
|
||||
&& (folder_meaning != FolderMeaning::Unknown
|
||||
|| !context.get_config_bool(Config::OnlyFetchMvbox).await?)
|
||||
{
|
||||
self.fetch_move_delete(context, session, folder.name(), folder_meaning)
|
||||
.await
|
||||
|
||||
@@ -1328,6 +1328,34 @@ CREATE INDEX gossip_timestamp_index ON gossip_timestamp (chat_id, fingerprint);
|
||||
.await?;
|
||||
}
|
||||
|
||||
inc_and_check(&mut migration_version, 138)?;
|
||||
if dbversion < migration_version {
|
||||
// `MvboxMove` now means "watch Inbox also and move chat messages from it". Preserve the old
|
||||
// behavior for `OnlyFetchMvbox` users.
|
||||
sql.execute_migration(
|
||||
"INSERT OR REPLACE INTO config (keyname, value)
|
||||
SELECT 'mvbox_move', '0'
|
||||
FROM config WHERE keyname='only_fetch_mvbox' AND value!='0'
|
||||
",
|
||||
migration_version,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
inc_and_check(&mut migration_version, 139)?;
|
||||
if dbversion < migration_version {
|
||||
// `OnlyFetchMvbox` is now 1 by default to avoid scanning unknown folders. But if the user
|
||||
// disabled `MvboxMove`, we have to keep `OnlyFetchMvbox` unset so that Inbox is watched.
|
||||
sql.execute_migration(
|
||||
"INSERT OR IGNORE INTO config (keyname, value)
|
||||
SELECT 'only_fetch_mvbox', '0'
|
||||
FROM config WHERE keyname='mvbox_move' AND value='0'
|
||||
",
|
||||
migration_version,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let new_version = sql
|
||||
.get_raw_config_int(VERSION_CFG)
|
||||
.await?
|
||||
|
||||
Reference in New Issue
Block a user