aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2018-09-14 17:38:14 +0200
committerMax Kostikov <max@kostikov.co>2018-09-14 17:38:14 +0200
commite931616011b2d5d41dd42927af30043ca6da9096 (patch)
tree6600628981533f1a7aae5513cb31e10ec2ace622 /include
parentab611e9ef3a2b4bdd4b4f33d72e43c1a6d28331f (diff)
downloadvolse-hubzilla-e931616011b2d5d41dd42927af30043ca6da9096.tar.gz
volse-hubzilla-e931616011b2d5d41dd42927af30043ca6da9096.tar.bz2
volse-hubzilla-e931616011b2d5d41dd42927af30043ca6da9096.zip
Save combined view while deleting first message in thread
Diffstat (limited to 'include')
-rw-r--r--include/message.php20
1 files changed, 20 insertions, 0 deletions
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;
}