From: Michael Date: Sun, 14 Jan 2018 22:53:00 +0000 (+0000) Subject: On participation send all the old content of the thread X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b7022963f3689a5152a06adb61ccc214463d5a1c;p=friendica.git On participation send all the old content of the thread --- diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index bf14b44d22..a5cd236a2b 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -116,7 +116,7 @@ class Diaspora $r = dba::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`, `fcontact`.`batch` AS `fbatch`, `fcontact`.`network` AS `fnetwork` FROM `participation` INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid` - LEFT JOIN `fcontact` ON `fcontact`.`url` = `contact`.`url` + INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid` WHERE `participation`.`iid` = ?", $thread); while ($contact = dba::fetch($r)) { @@ -2180,13 +2180,19 @@ class Diaspora $contact_id = Contact::getIdForURL($author); if (!$contact_id) { - logger('Author not found: '.$author); + logger('Contact not found: '.$author); + return false; + } + + $person = self::personByHandle($author); + if (!is_array($person)) { + logger("Person not found: ".$author); return false; } $item = dba::selectFirst('item', ['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => false]); if (!DBM::is_result($item)) { - logger('Item not found: '.$parent_guid); + logger('Item not found, no origin or private: '.$parent_guid); return false; } @@ -2198,8 +2204,24 @@ class Diaspora $server = $author; } - logger('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server); - dba::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'server' => $server]); + logger('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, LOGGER_DEBUG); + dba::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]); + + // Send all existing comments and likes to the requesting server + $comments = dba::p("SELECT `item`.`id`, `item`.`verb`, `contact`.`self` + FROM `item` + INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + WHERE `item`.`parent` = ? AND `item`.`id` != `item`.`parent`", $item['id']); + while ($comment = dba::fetch($comments)) { + if ($comment['verb'] == ACTIVITY_POST) { + $cmd = $comment['self'] ? 'comment-new' : 'comment-import'; + } else { + $cmd = $comment['self'] ? 'like' : 'comment-import'; + } + logger("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, LOGGER_DEBUG); + Worker::add(PRIORITY_HIGH, 'Delivery', $cmd, $comment['id'], $contact_id); + } + dba::close($comments); return true; }