Skip to content

Commit 53572fc

Browse files
committed
fix: migration: Set bcc_self=1 if it's unset and delete_server_after!=1 (#6432)
Users report that in a setup with Android (1.50.4 from F-Droid) and Desktop (1.48.0 x86_64 .deb release) and chatmail account `bcc_self` was reverted to 0 on Android, resulting in messages sent from Android not appearing on Desktop. This might happen because of the bug in migration #127, it doesn't handle `delete_server_after` > 1. Existing chatmail configurations having `delete_server_after` != 1 ("delete at once") should get `bcc_self` enabled, they may be multidevice configurations: - Before migration #127, `delete_server_after` was set to 0 upon a backup export, but then `bcc_self` is enabled instead (whose default is changed to 0 for chatmail). - The user might set `delete_server_after` to a value other than 0 or 1 when that was possible in UIs. So let's add another migration fixing this. But still don't check `is_chatmail` for simplicity.
1 parent 53dca8c commit 53572fc

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/sql/migrations.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,11 +1123,7 @@ CREATE INDEX msgs_status_updates_index2 ON msgs_status_updates (uid);
11231123

11241124
inc_and_check(&mut migration_version, 127)?;
11251125
if dbversion < migration_version {
1126-
// Existing chatmail configurations having `delete_server_after` disabled should get
1127-
// `bcc_self` enabled, they may be multidevice configurations because before,
1128-
// `delete_server_after` was set to 0 upon a backup export for them, but together with this
1129-
// migration `bcc_self` is enabled instead (whose default is changed to 0 for chatmail). We
1130-
// don't check `is_chatmail` for simplicity.
1126+
// This is buggy: `delete_server_after` > 1 isn't handled. Migration #129 fixes this.
11311127
sql.execute_migration(
11321128
"INSERT OR IGNORE INTO config (keyname, value)
11331129
SELECT 'bcc_self', '1'
@@ -1156,6 +1152,25 @@ CREATE INDEX msgs_status_updates_index2 ON msgs_status_updates (uid);
11561152
.await?;
11571153
}
11581154

1155+
inc_and_check(&mut migration_version, 129)?;
1156+
if dbversion < migration_version {
1157+
// Existing chatmail configurations having `delete_server_after` != "delete at once" should
1158+
// get `bcc_self` enabled, they may be multidevice configurations:
1159+
// - Before migration #127, `delete_server_after` was set to 0 upon a backup export, but
1160+
// then `bcc_self` is enabled instead (whose default is changed to 0 for chatmail).
1161+
// - The user might set `delete_server_after` to a value other than 0 or 1 when that was
1162+
// possible in UIs.
1163+
// We don't check `is_chatmail` for simplicity.
1164+
sql.execute_migration(
1165+
"INSERT OR IGNORE INTO config (keyname, value)
1166+
SELECT 'bcc_self', '1'
1167+
FROM config WHERE keyname='delete_server_after' AND value!='1'
1168+
",
1169+
migration_version,
1170+
)
1171+
.await?;
1172+
}
1173+
11591174
let new_version = sql
11601175
.get_raw_config_int(VERSION_CFG)
11611176
.await?

0 commit comments

Comments
 (0)