mirror of
https://github.com/chatmail/core.git
synced 2026-04-27 02:16:29 +03:00
feat: Add Config::FixIsChatmail
Add a config option preventing autoconfiguring `IsChatmail` for tests.
This commit is contained in:
@@ -257,6 +257,9 @@ pub enum Config {
|
|||||||
/// True if account is a chatmail account.
|
/// True if account is a chatmail account.
|
||||||
IsChatmail,
|
IsChatmail,
|
||||||
|
|
||||||
|
/// True if `IsChatmail` mustn't be autoconfigured. For tests.
|
||||||
|
FixIsChatmail,
|
||||||
|
|
||||||
/// True if account is muted.
|
/// True if account is muted.
|
||||||
IsMuted,
|
IsMuted,
|
||||||
|
|
||||||
|
|||||||
@@ -454,15 +454,27 @@ async fn configure(ctx: &Context, param: &mut LoginParam) -> Result<()> {
|
|||||||
|
|
||||||
progress!(ctx, 900);
|
progress!(ctx, 900);
|
||||||
|
|
||||||
if imap_session.is_chatmail() {
|
let is_chatmail = match ctx.get_config_bool(Config::FixIsChatmail).await? {
|
||||||
ctx.set_config(Config::IsChatmail, Some("1")).await?;
|
false => {
|
||||||
|
let is_chatmail = imap_session.is_chatmail();
|
||||||
|
ctx.set_config(
|
||||||
|
Config::IsChatmail,
|
||||||
|
Some(match is_chatmail {
|
||||||
|
false => "0",
|
||||||
|
true => "1",
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
is_chatmail
|
||||||
|
}
|
||||||
|
true => ctx.get_config_bool(Config::IsChatmail).await?,
|
||||||
|
};
|
||||||
|
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::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?;
|
||||||
ctx.set_config(Config::E2eeEnabled, Some("1")).await?;
|
ctx.set_config(Config::E2eeEnabled, Some("1")).await?;
|
||||||
} else {
|
|
||||||
ctx.set_config(Config::IsChatmail, Some("0")).await?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let create_mvbox = ctx.should_watch_mvbox().await?;
|
let create_mvbox = ctx.should_watch_mvbox().await?;
|
||||||
|
|||||||
@@ -814,6 +814,12 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.insert("is_chatmail", self.is_chatmail().await?.to_string());
|
res.insert("is_chatmail", self.is_chatmail().await?.to_string());
|
||||||
|
res.insert(
|
||||||
|
"fix_is_chatmail",
|
||||||
|
self.get_config_bool(Config::FixIsChatmail)
|
||||||
|
.await?
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
res.insert(
|
res.insert(
|
||||||
"is_muted",
|
"is_muted",
|
||||||
self.get_config_bool(Config::IsMuted).await?.to_string(),
|
self.get_config_bool(Config::IsMuted).await?.to_string(),
|
||||||
|
|||||||
@@ -466,11 +466,13 @@ pub async fn convert_folder_meaning(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn inbox_fetch_idle(ctx: &Context, imap: &mut Imap, mut session: Session) -> Result<Session> {
|
async fn inbox_fetch_idle(ctx: &Context, imap: &mut Imap, mut session: Session) -> Result<Session> {
|
||||||
ctx.set_config_internal(
|
if !ctx.get_config_bool(Config::FixIsChatmail).await? {
|
||||||
Config::IsChatmail,
|
ctx.set_config_internal(
|
||||||
crate::config::from_bool(session.is_chatmail()),
|
Config::IsChatmail,
|
||||||
)
|
crate::config::from_bool(session.is_chatmail()),
|
||||||
.await?;
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
// Update quota no more than once a minute.
|
// Update quota no more than once a minute.
|
||||||
if ctx.quota_needs_update(60).await {
|
if ctx.quota_needs_update(60).await {
|
||||||
|
|||||||
Reference in New Issue
Block a user