From 755b245495e4898a71cdd9c3e7430c529f41fbde Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 30 Nov 2024 00:15:37 +0000 Subject: [PATCH] fix: mark Saved Messages chat as protected if it exists Saved Messages chat is created as protected, but for existing accounts we need to do this in a migration. --- src/sql/migrations.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index 06ed60cdf..15d89c6f1 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -1070,6 +1070,24 @@ CREATE INDEX msgs_status_updates_index2 ON msgs_status_updates (uid); .await?; } + inc_and_check(&mut migration_version, 124)?; + if dbversion < migration_version { + // Mark Saved Messages chat as protected if it already exists. + sql.execute_migration( + "UPDATE chats + SET protected=1 -- ProtectionStatus::Protected + WHERE type==100 -- Chattype::Single + AND EXISTS ( + SELECT 1 FROM chats_contacts cc + WHERE cc.chat_id==chats.id + AND cc.contact_id=1 + ) + ", + migration_version, + ) + .await?; + } + let new_version = sql .get_raw_config_int(VERSION_CFG) .await?