mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
Compare commits
2 Commits
v2.7.0
...
iequidoo/m
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a16a7d6682 | ||
|
|
a5d0d4c126 |
@@ -164,7 +164,6 @@ pub enum Config {
|
|||||||
|
|
||||||
/// True if chat messages should be moved to a separate folder. Auto-sent messages like sync
|
/// True if chat messages should be moved to a separate folder. Auto-sent messages like sync
|
||||||
/// ones are moved there anyway.
|
/// ones are moved there anyway.
|
||||||
#[strum(props(default = "1"))]
|
|
||||||
MvboxMove,
|
MvboxMove,
|
||||||
|
|
||||||
/// Watch for new messages in the "Mvbox" (aka DeltaChat folder) only.
|
/// Watch for new messages in the "Mvbox" (aka DeltaChat folder) only.
|
||||||
@@ -596,9 +595,17 @@ impl Context {
|
|||||||
.unwrap_or_default())
|
.unwrap_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if chat messages should be moved to the mvbox ("DeltaChat" folder).
|
||||||
|
pub(crate) async fn should_move_to_mvbox(&self) -> Result<bool> {
|
||||||
|
match self.get_config_bool_opt(Config::MvboxMove).await? {
|
||||||
|
Some(val) => Ok(val),
|
||||||
|
None => Ok(!self.get_config_bool(Config::IsChatmail).await?),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if movebox ("DeltaChat" folder) should be watched.
|
/// Returns true if movebox ("DeltaChat" folder) should be watched.
|
||||||
pub(crate) async fn should_watch_mvbox(&self) -> Result<bool> {
|
pub(crate) async fn should_watch_mvbox(&self) -> Result<bool> {
|
||||||
Ok(self.get_config_bool(Config::MvboxMove).await?
|
Ok(self.should_move_to_mvbox().await?
|
||||||
|| self.get_config_bool(Config::OnlyFetchMvbox).await?
|
|| self.get_config_bool(Config::OnlyFetchMvbox).await?
|
||||||
|| !self.get_config_bool(Config::IsChatmail).await?)
|
|| !self.get_config_bool(Config::IsChatmail).await?)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,15 @@ async fn test_delete_server_after_default() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_should_move_to_mvbox() -> Result<()> {
|
||||||
|
let alice = &TestContext::new_alice().await;
|
||||||
|
assert!(alice.should_move_to_mvbox().await?);
|
||||||
|
alice.set_config_bool(Config::IsChatmail, true).await?;
|
||||||
|
assert!(!alice.should_move_to_mvbox().await?);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
const SAVED_MESSAGES_DEDUPLICATED_FILE: &str = "969142cb84015bc135767bc2370934a.png";
|
const SAVED_MESSAGES_DEDUPLICATED_FILE: &str = "969142cb84015bc135767bc2370934a.png";
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
|||||||
@@ -529,7 +529,6 @@ async fn configure(ctx: &Context, param: &EnteredLoginParam) -> Result<Configure
|
|||||||
};
|
};
|
||||||
if is_chatmail {
|
if is_chatmail {
|
||||||
ctx.set_config(Config::SentboxWatch, None).await?;
|
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::OnlyFetchMvbox, None).await?;
|
||||||
ctx.set_config(Config::ShowEmails, None).await?;
|
ctx.set_config(Config::ShowEmails, None).await?;
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/imap.rs
16
src/imap.rs
@@ -482,7 +482,10 @@ impl Imap {
|
|||||||
false => session.is_chatmail(),
|
false => session.is_chatmail(),
|
||||||
true => context.get_config_bool(Config::IsChatmail).await?,
|
true => context.get_config_bool(Config::IsChatmail).await?,
|
||||||
};
|
};
|
||||||
let create_mvbox = !is_chatmail || context.get_config_bool(Config::MvboxMove).await?;
|
let create_mvbox = context
|
||||||
|
.get_config_bool_opt(Config::MvboxMove)
|
||||||
|
.await?
|
||||||
|
.unwrap_or(!is_chatmail);
|
||||||
self.configure_folders(context, &mut session, create_mvbox)
|
self.configure_folders(context, &mut session, create_mvbox)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
@@ -1776,14 +1779,17 @@ impl Imap {
|
|||||||
context
|
context
|
||||||
.set_config_internal(Config::ConfiguredInboxFolder, Some("INBOX"))
|
.set_config_internal(Config::ConfiguredInboxFolder, Some("INBOX"))
|
||||||
.await?;
|
.await?;
|
||||||
|
for (config, name) in folder_configs {
|
||||||
|
context.set_config_internal(config, Some(&name)).await?;
|
||||||
|
}
|
||||||
if let Some(mvbox_folder) = mvbox_folder {
|
if let Some(mvbox_folder) = mvbox_folder {
|
||||||
info!(context, "Setting MVBOX FOLDER TO {}", &mvbox_folder);
|
info!(context, "Setting MVBOX FOLDER TO {}", &mvbox_folder);
|
||||||
context
|
context
|
||||||
.set_config_internal(Config::ConfiguredMvboxFolder, Some(mvbox_folder))
|
.set_config_internal(Config::ConfiguredMvboxFolder, Some(mvbox_folder))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
} else if context.get_config_bool_opt(Config::MvboxMove).await? == Some(true) {
|
||||||
for (config, name) in folder_configs {
|
warn!(context, "Will retry configuring MVBOX on reconnect.");
|
||||||
context.set_config_internal(config, Some(&name)).await?;
|
return Ok(());
|
||||||
}
|
}
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
@@ -1994,7 +2000,7 @@ async fn needs_move_to_mvbox(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !context.get_config_bool(Config::MvboxMove).await? {
|
if !context.should_move_to_mvbox().await? {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user