]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Receiver.php
Merge pull request #7570 from nupplaphil/bug/friendica-7298
[friendica.git] / src / Protocol / ActivityPub / Receiver.php
index 1d425600d81b76ded4dda6f4819c1690e60e2751..bb676b396e338113ee517be084f8dfde49ec994e 100644 (file)
@@ -386,15 +386,14 @@ class Receiver
                        case 'as:Announce':
                                if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
                                        $profile = APContact::getByURL($object_data['actor']);
-                                       if ($profile['type'] == 'Person') {
-                                               // Reshared posts from persons appear as summary at the bottom
-                                               // If this isn't set, then a single reshare appears on top. This is used for groups.
-                                               $object_data['thread-completion'] = true;
-                                       }
+                                       // Reshared posts from persons appear as summary at the bottom
+                                       // If this isn't set, then a single reshare appears on top. This is used for groups.
+                                       $object_data['thread-completion'] = ($profile['type'] != 'Group');
+
                                        ActivityPub\Processor::createItem($object_data);
 
                                        // Add the bottom reshare information only for persons
-                                       if ($profile['type'] == 'Person') {
+                                       if ($profile['type'] != 'Group') {
                                                $announce_object_data = self::processObject($activity);
                                                $announce_object_data['name'] = $type;
                                                $announce_object_data['author'] = JsonLD::fetchElement($activity, 'as:actor', '@id');
@@ -556,7 +555,7 @@ class Receiver
                                // Check if the potential receiver is following the actor
                                // Exception: The receiver is targetted via "to" or this is a comment
                                if ((($element != 'as:to') && empty($replyto)) || ($contact['contact-type'] == Contact::TYPE_COMMUNITY)) {
-                                       $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
+                                       $networks = Protocol::FEDERATED;
                                        $condition = ['nurl' => Strings::normaliseLink($actor), 'rel' => [Contact::SHARING, Contact::FRIEND],
                                                'network' => $networks, 'archive' => false, 'pending' => false, 'uid' => $contact['uid']];
 
@@ -591,7 +590,7 @@ class Receiver
        public static function getReceiverForActor($actor, $tags)
        {
                $receivers = [];
-               $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
+               $networks = Protocol::FEDERATED;
                $condition = ['nurl' => Strings::normaliseLink($actor), 'rel' => [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER],
                        'network' => $networks, 'archive' => false, 'pending' => false];
                $contacts = DBA::select('contact', ['uid', 'rel'], $condition);
@@ -657,27 +656,14 @@ class Receiver
         */
        public static function switchContact($cid, $uid, $url)
        {
-               $profile = ActivityPub::probeProfile($url);
-               if (empty($profile)) {
-                       return;
-               }
-
-               Logger::log('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub');
-
-               $photo = defaults($profile, 'photo', null);
-               unset($profile['photo']);
-               unset($profile['baseurl']);
-               unset($profile['guid']);
-
-               $profile['nurl'] = Strings::normaliseLink($profile['url']);
-               DBA::update('contact', $profile, ['id' => $cid]);
+               Contact::updateFromProbe($cid, '', true);
 
-               Contact::updateAvatar($photo, $uid, $cid);
+               Logger::log('Switch contact ' . $cid . ' (' . $url . ') for user ' . $uid . ' to ActivityPub');
 
                // Send a new follow request to be sure that the connection still exists
                if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) {
-                       ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid);
-                       Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, Logger::DEBUG);
+                       ActivityPub\Transmitter::sendActivity('Follow', $url, $uid);
+                       Logger::log('Send a new follow request to ' . $url . ' for user ' . $uid, Logger::DEBUG);
                }
        }