From 6002f54ce1d4465c01128067f2c124ff8732b314 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Tue, 7 Jan 2020 16:35:31 +0300 Subject: [PATCH] Set autodelete timer columns for outgoing messages --- src/chat.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/chat.rs b/src/chat.rs index 5d8f88da1..b81c066ff 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -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 if sql::execute( context, &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![ new_rfc724_mid, self.id, @@ -902,6 +906,8 @@ impl Chat { new_in_reply_to, new_references, location_id as i32, + autodelete_timer, + autodelete_timestamp ] ).is_ok() { msg_id = sql::get_rowid(