Skip to content

Commit

Permalink
fix: mark Saved Messages chat as protected if it exists
Browse files Browse the repository at this point in the history
Saved Messages chat is created as protected,
but for existing accounts we need to do this in a migration.
  • Loading branch information
link2xt committed Nov 30, 2024
1 parent dc5fcdf commit c9afe18
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/sql/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit c9afe18

Please sign in to comment.