Compare commits

...

1 Commits

Author SHA1 Message Date
Hocuri
a25f68e358 fix: Reset options that are not available for chatmail
We don't show these 3 options in the UI for chatmail profiles.

There were reports from users, who had these options set to something
else, and then couldn't change them.

They are not supposed to be something else for chatmail profiles.

fix https://github.com/chatmail/core/issues/7622
2025-12-18 17:14:49 +01:00
2 changed files with 26 additions and 3 deletions

View File

@@ -214,7 +214,7 @@ impl Sql {
// this should be done before updates that use high-level objects that
// rely themselves on the low-level structure.
let recode_avatar = migrations::run(context, self)
let (recode_avatar, update_email_configs) = migrations::run(context, self)
.await
.context("failed to run migrations")?;
@@ -242,6 +242,22 @@ impl Sql {
}
}
// Reset some options if IsChatmail is true,
// because there were reports from users who had these options set to something else,
// and then couldn't change them because they are hidden in the UI for chatmail profiles
if update_email_configs && context.get_config_bool(Config::IsChatmail).await? {
// The default for MvboxMove is actually "1", and it's usually set to "0" in `configure.rs`.
context
.set_config_internal(Config::MvboxMove, Some("0"))
.await?;
context
.set_config_internal(Config::OnlyFetchMvbox, None)
.await?;
context
.set_config_internal(Config::ShowEmails, None)
.await?;
}
Ok(())
}

View File

@@ -31,7 +31,7 @@ tokio::task_local! {
static STOP_MIGRATIONS_AT: i32;
}
pub async fn run(context: &Context, sql: &Sql) -> Result<bool> {
pub async fn run(context: &Context, sql: &Sql) -> Result<(bool, bool)> {
let mut exists_before_update = false;
let mut dbversion_before_update = DBVERSION;
@@ -69,6 +69,7 @@ pub async fn run(context: &Context, sql: &Sql) -> Result<bool> {
let dbversion = dbversion_before_update;
let mut recode_avatar = false;
let mut update_email_configs = false;
if dbversion < 1 {
sql.execute_migration(
@@ -1466,6 +1467,12 @@ ALTER TABLE contacts ADD COLUMN name_normalized TEXT;
.await?;
}
inc_and_check(&mut migration_version, 144)?;
if dbversion < migration_version {
update_email_configs = true;
sql.set_db_version(migration_version).await?;
}
let new_version = sql
.get_raw_config_int(VERSION_CFG)
.await?
@@ -1480,7 +1487,7 @@ ALTER TABLE contacts ADD COLUMN name_normalized TEXT;
}
info!(context, "Database version: v{new_version}.");
Ok(recode_avatar)
Ok((recode_avatar, update_email_configs))
}
fn migrate_key_contacts(