From e931616011b2d5d41dd42927af30043ca6da9096 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Sep 2018 17:38:14 +0200 Subject: Save combined view while deleting first message in thread --- include/message.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/message.php b/include/message.php index 4a673b961..73471f573 100644 --- a/include/message.php +++ b/include/message.php @@ -503,6 +503,26 @@ function private_messages_drop($channel_id, $messageitem_id, $drop_conversation intval($messageitem_id), intval($channel_id) ); + + // If it was a first message in thread + $z = q("SELECT * FROM mail WHERE mid = '%s' AND channel_id = %d", + dbesc($x[0]['parent_mid']), + intval($channel_id) + ); + if (! $z) { + // Get new first message... + $r = q("SELECT * FROM mail WHERE conv_guid = '%s' AND channel_id = %d ORDER BY id ASC LIMIT 1", + dbesc($x[0]['conv_guid']), + intval($channel_id) + ); + // ...and refer whole thread to it + q("UPDATE mail SET parent_mid = '%s', mail_isreply = abs(mail_isreply - 1) WHERE conv_guid = '%s' AND channel_id = %d", + dbesc($r[0]['mid']), + dbesc($x[0]['conv_guid']), + intval($channel_id) + ); + } + build_sync_packet($channel_id,array('mail' => array(encode_mail($x,true)))); return true; } -- cgit v1.2.3