- logger('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server);
- dba::insert('participation', ['item' => $item['id'], 'contact' => $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);