return false;
}
- $author_parts = explode('@', $author);
- if (isset($author_parts[1])) {
- $server = $author_parts[1];
- } else {
- // Should never happen
- $server = $author;
+ $person = self::personByHandle($author);
+ if (!is_array($person)) {
+ Logger::log("Person not found: ".$author);
+ return false;
}
- Logger::log('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, Logger::DEBUG);
+ $author_contact = self::authorContactByUrl($contact, $person, $importer["uid"]);
- if (!DBA::exists('participation', ['iid' => $item['id'], 'server' => $server])) {
- DBA::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]);
- }
+ // Store participation
+ $datarray = [];
+
+ $datarray["protocol"] = Conversation::PARCEL_DIASPORA;
+
+ $datarray["uid"] = $importer["uid"];
+ $datarray["contact-id"] = $author_contact["cid"];
+ $datarray["network"] = $author_contact["network"];
+
+ $datarray["owner-link"] = $datarray["author-link"] = $person["url"];
+ $datarray["owner-id"] = $datarray["author-id"] = Contact::getIdForURL($person["url"], 0);
+
+ $datarray["guid"] = $guid;
+ $datarray["uri"] = self::getUriFromGuid($author, $guid);
+
+ $datarray["verb"] = Activity::FOLLOW;
+ $datarray["gravity"] = GRAVITY_ACTIVITY;
+ $datarray["parent-uri"] = $parent_item["uri"];
+
+ $datarray["object-type"] = Activity\ObjectType::NOTE;
+
+ $datarray["body"] = Activity::FOLLOW;
+
+ // Diaspora doesn't provide a date for a participation
+ $datarray["changed"] = $datarray["created"] = $datarray["edited"] = DateTimeFormat::utcNow();
+
+ $message_id = Item::insert($datarray);
+
+ Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]);
// Send all existing comments and likes to the requesting server
- $comments = Item::select(['id', 'uri-id', 'parent', 'verb', 'self'], ['parent' => $item['id']]);
- $comments = Item::select(['id', 'parent', 'verb', 'self'], ['parent' => $parent_item['id']]);
++ $comments = Item::select(['id', 'uri-id', 'parent', 'verb', 'self'], ['parent' => $parent_item['id']]);
while ($comment = Item::fetch($comments)) {
if ($comment['id'] == $comment['parent']) {
continue;
}
- Logger::info('Deliver participation', ['item' => $comment['id'], 'contact' => $contact_id]);
- if (Worker::add(PRIORITY_HIGH, 'Delivery', Delivery::POST, $comment['id'], $contact_id)) {
+ Logger::info('Deliver participation', ['item' => $comment['id'], 'contact' => $author_contact["cid"]]);
+ if (Worker::add(PRIORITY_HIGH, 'Delivery', Delivery::POST, $comment['id'], $author_contact["cid"])) {
- ItemDeliveryData::incrementQueueCount($comment['id'], 1);
+ Post\DeliveryData::incrementQueueCount($comment['uri-id'], 1);
}
}
DBA::close($comments);