From a25f68e35819575109f636a654a1f784646dd413 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Thu, 18 Dec 2025 17:14:49 +0100 Subject: [PATCH] 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 --- src/sql.rs | 18 +++++++++++++++++- src/sql/migrations.rs | 11 +++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/sql.rs b/src/sql.rs index f0405c0758..89d7ef6044 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -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(()) } diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index 80ac2c564a..e3e27dba82 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -31,7 +31,7 @@ tokio::task_local! { static STOP_MIGRATIONS_AT: i32; } -pub async fn run(context: &Context, sql: &Sql) -> Result { +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 { 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(