mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +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
|
||||
/// ones are moved there anyway.
|
||||
#[strum(props(default = "1"))]
|
||||
MvboxMove,
|
||||
|
||||
/// Watch for new messages in the "Mvbox" (aka DeltaChat folder) only.
|
||||
@@ -596,9 +595,17 @@ impl Context {
|
||||
.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.
|
||||
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::IsChatmail).await?)
|
||||
}
|
||||
|
||||
@@ -185,6 +185,15 @@ async fn test_delete_server_after_default() -> Result<()> {
|
||||
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";
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
|
||||
@@ -529,7 +529,6 @@ async fn configure(ctx: &Context, param: &EnteredLoginParam) -> Result<Configure
|
||||
};
|
||||
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?;
|
||||
}
|
||||
|
||||
16
src/imap.rs
16
src/imap.rs
@@ -482,7 +482,10 @@ impl Imap {
|
||||
false => session.is_chatmail(),
|
||||
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)
|
||||
.await?;
|
||||
}
|
||||
@@ -1776,14 +1779,17 @@ impl Imap {
|
||||
context
|
||||
.set_config_internal(Config::ConfiguredInboxFolder, Some("INBOX"))
|
||||
.await?;
|
||||
for (config, name) in folder_configs {
|
||||
context.set_config_internal(config, Some(&name)).await?;
|
||||
}
|
||||
if let Some(mvbox_folder) = mvbox_folder {
|
||||
info!(context, "Setting MVBOX FOLDER TO {}", &mvbox_folder);
|
||||
context
|
||||
.set_config_internal(Config::ConfiguredMvboxFolder, Some(mvbox_folder))
|
||||
.await?;
|
||||
}
|
||||
for (config, name) in folder_configs {
|
||||
context.set_config_internal(config, Some(&name)).await?;
|
||||
} else if context.get_config_bool_opt(Config::MvboxMove).await? == Some(true) {
|
||||
warn!(context, "Will retry configuring MVBOX on reconnect.");
|
||||
return Ok(());
|
||||
}
|
||||
context
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user