Update msglib.php

This commit is contained in:
Max Kostikov 2018-09-16 00:43:45 +02:00
parent 034441bd13
commit 585bdf562a

View File

@ -10,18 +10,14 @@ function msg_drop($message_id, $channel_id, $conv_guid) {
$channel_id $channel_id
); );
// If it was a first message in thread // Get new first message...
$z = q("SELECT * FROM mail WHERE mid = '%s' AND channel_id = %d", $r = q("SELECT mid, parent_mid FROM mail WHERE conv_guid = '%s' AND channel_id = %d ORDER BY id ASC LIMIT 1",
$message_id, $conv_guid,
$channel_id $channel_id
); );
if (! $z) { // ...and if wasn't first before...
// Get new first message... if ($r[0]['mid'] != $r[0]['parent_mid']) {
$r = q("SELECT mid FROM mail WHERE conv_guid = '%s' AND channel_id = %d ORDER BY id ASC LIMIT 1", // ...refer whole thread to it
$conv_guid,
$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", 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($r[0]['mid']),
$conv_guid, $conv_guid,