]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into post-delivery-data
authorMichael <heluecht@pirati.ca>
Tue, 5 May 2020 14:08:29 +0000 (14:08 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 5 May 2020 14:08:29 +0000 (14:08 +0000)
1  2 
database.sql
src/Protocol/Diaspora.php
src/Worker/Notifier.php

diff --cc database.sql
Simple merge
index 42e0fb0a27876085cab40af9a59d9aea45487d66,a0047d008a4ab3d5877161ffd4e9486f17553435..3cdf21b57ca66ad7c744ee14345bc4e4289ee20e
@@@ -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);
Simple merge