Update msg related location when message is deleted

resolves #843
This commit is contained in:
Nico de Haen
2019-11-16 11:04:56 +01:00
parent d808bfe400
commit c690a64462

View File

@@ -841,6 +841,12 @@ pub fn get_mime_headers(context: &Context, msg_id: MsgId) -> Option<String> {
pub fn delete_msgs(context: &Context, msg_ids: &[MsgId]) {
for msg_id in msg_ids.iter() {
if let Ok(msg) = Message::load_from_db(context, *msg_id) {
if msg.location_id > 0 {
update_location_chat_id(context, msg.location_id, DC_CHAT_ID_TRASH);
}
} else {
}
update_msg_chat_id(context, *msg_id, DC_CHAT_ID_TRASH);
job_add(
context,
@@ -871,6 +877,16 @@ fn update_msg_chat_id(context: &Context, msg_id: MsgId, chat_id: u32) -> bool {
.is_ok()
}
fn update_location_chat_id(context: &Context, location_id: u32, chat_id: u32) -> bool {
sql::execute(
context,
&context.sql,
"UPDATE locations SET chat_id=? WHERE id=?;",
params![chat_id as i32, location_id as i32],
)
.is_ok()
}
pub fn markseen_msgs(context: &Context, msg_ids: &[MsgId]) -> bool {
if msg_ids.is_empty() {
return false;