From: Michael Date: Tue, 5 May 2020 14:08:29 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/develop' into post-delivery-data X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2ee14bf5fe6642d0083d43404451b6b1fa5ce4ce;p=friendica.git Merge remote-tracking branch 'upstream/develop' into post-delivery-data --- 2ee14bf5fe6642d0083d43404451b6b1fa5ce4ce diff --cc src/Protocol/Diaspora.php index 42e0fb0a27,a0047d008a..3cdf21b57c --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@@ -2278,30 -2286,54 +2286,54 @@@ class Diaspor 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);