Set autodelete timer columns for outgoing messages

This commit is contained in:
Alexander Krotov
2020-01-07 16:35:31 +03:00
parent a830d499eb
commit 6002f54ce1

View File

@@ -882,12 +882,16 @@ impl Chat {
); );
} }
// get autodelete timer
let autodelete_timer = Some(get_autodelete_timer(context, self.id)).filter(|&x| x != 0);
let autodelete_timestamp = autodelete_timer.map(|x| timestamp + i64::from(x));
// add message to the database // add message to the database
if sql::execute( if sql::execute(
context, context,
&context.sql, &context.sql,
"INSERT INTO msgs (rfc724_mid, chat_id, from_id, to_id, timestamp, type, state, txt, param, hidden, mime_in_reply_to, mime_references, location_id) VALUES (?,?,?,?,?, ?,?,?,?,?, ?,?,?);", "INSERT INTO msgs (rfc724_mid, chat_id, from_id, to_id, timestamp, type, state, txt, param, hidden, mime_in_reply_to, mime_references, location_id, autodelete_timer, autodelete_timestamp) VALUES (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?);",
params![ params![
new_rfc724_mid, new_rfc724_mid,
self.id, self.id,
@@ -902,6 +906,8 @@ impl Chat {
new_in_reply_to, new_in_reply_to,
new_references, new_references,
location_id as i32, location_id as i32,
autodelete_timer,
autodelete_timestamp
] ]
).is_ok() { ).is_ok() {
msg_id = sql::get_rowid( msg_id = sql::get_rowid(