diff --git a/src/chat.rs b/src/chat.rs index 8953c82ea..f75b8bb71 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -637,7 +637,7 @@ pub fn create_or_lookup_by_contact_id( context, &context.sql, format!( - "INSERT INTO chats (type, name, param, blocked, grpid) VALUES({}, '{}', '{}', {}, '{}')", + "INSERT INTO chats (type, name, param, blocked, grpid, created_timestamp) VALUES({}, '{}', '{}', {}, '{}', {})", 100, chat_name, match contact_id { @@ -650,6 +650,7 @@ pub fn create_or_lookup_by_contact_id( }, create_blocked as u8, contact.get_addr(), + dc_create_smeared_timestamp(context), ), params![], )?; @@ -1388,7 +1389,7 @@ pub fn create_group_chat( sql::execute( context, &context.sql, - "INSERT INTO chats (type, name, grpid, param) VALUES(?, ?, ?, \'U=1\');", + "INSERT INTO chats (type, name, grpid, param, created_timestamp) VALUES(?, ?, ?, \'U=1\', ?);", params![ if verified != VerifiedStatus::Unverified { Chattype::VerifiedGroup @@ -1396,7 +1397,8 @@ pub fn create_group_chat( Chattype::Group }, chat_name.as_ref(), - grpid + grpid, + dc_create_smeared_timestamp(context), ], )?; diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index c866e0eba..e07f1641f 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -1439,7 +1439,7 @@ fn create_group_record( if sql::execute( context, &context.sql, - "INSERT INTO chats (type, name, grpid, blocked) VALUES(?, ?, ?, ?);", + "INSERT INTO chats (type, name, grpid, blocked, created_timestamp) VALUES(?, ?, ?, ?, ?);", params![ if VerifiedStatus::Unverified != create_verified { Chattype::VerifiedGroup @@ -1449,6 +1449,7 @@ fn create_group_record( grpname.as_ref(), grpid.as_ref(), create_blocked, + dc_create_smeared_timestamp(context), ], ) .is_err() diff --git a/src/sql.rs b/src/sql.rs index 7170fbdca..744378c6b 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -829,6 +829,14 @@ fn open( update_icons = true; sql.set_raw_config_int(context, "dbversion", 59)?; } + if dbversion < 60 { + info!(context, "[migration] v60"); + sql.execute( + "ALTER TABLE chats ADD COLUMN created_timestamp INTEGER DEFAULT 0;", + NO_PARAMS, + )?; + sql.set_raw_config_int(context, "dbversion", 60)?; + } // (2) updates that require high-level objects // (the structure is complete now and all objects are usable)