]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Receiver.php
spelling: the
[friendica.git] / src / Protocol / ActivityPub / Receiver.php
index 4b8f1557b88e3aaaa29e85c01406dee915052021..a18a1092848a366bd878408dc1568d577f007d00 100644 (file)
@@ -74,11 +74,11 @@ class Receiver
        const TARGET_ANSWER = 6;
        const TARGET_GLOBAL = 7;
 
-       const COMPLETION_NONE    = 0;
-       const COMPLETION_ANNOUCE = 1;
-       const COMPLETION_RELAY   = 2;
-       const COMPLETION_MANUAL  = 3;
-       const COMPLETION_AUTO    = 4;
+       const COMPLETION_NONE     = 0;
+       const COMPLETION_ANNOUNCE = 1;
+       const COMPLETION_RELAY    = 2;
+       const COMPLETION_MANUAL   = 3;
+       const COMPLETION_AUTO     = 4;
 
        /**
         * Checks incoming message from the inbox
@@ -248,7 +248,7 @@ class Receiver
         * Fetches the object type for a given object id
         *
         * @param array   $activity
-        * @param string  $object_id Object ID of the the provided object
+        * @param string  $object_id Object ID of the provided object
         * @param integer $uid       User ID
         *
         * @return string with object type or NULL
@@ -643,7 +643,7 @@ class Receiver
                        }
                }
 
-               $decouple = DI::config()->get('system', 'decoupled_receiver') && !in_array($completion, [self::COMPLETION_MANUAL, self::COMPLETION_ANNOUCE]);
+               $decouple = DI::config()->get('system', 'decoupled_receiver') && !in_array($completion, [self::COMPLETION_MANUAL, self::COMPLETION_ANNOUNCE]);
 
                if ($decouple && ($trust_source || DI::config()->get('debug', 'ap_inbox_store_untrusted'))) {
                        $object_data = Queue::add($object_data, $type, $uid, $http_signer, $push, $trust_source);
@@ -731,7 +731,7 @@ class Receiver
                        case 'as:Announce':
                                if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
                                        if (!Item::searchByLink($object_data['object_id'], $uid)) {
-                                               if (ActivityPub\Processor::fetchMissingActivity($object_data['object_id'], [], $object_data['actor'], self::COMPLETION_ANNOUCE, $uid)) {
+                                               if (ActivityPub\Processor::fetchMissingActivity($object_data['object_id'], [], $object_data['actor'], self::COMPLETION_ANNOUNCE, $uid)) {
                                                        Logger::debug('Created announced id', ['uid' => $uid, 'id' => $object_data['object_id']]);
                                                        Queue::remove($object_data);
                                                } else {
@@ -1067,7 +1067,7 @@ class Receiver
        {
                $reply = $receivers = $profile = [];
 
-               // When it is an answer, we inherite the receivers from the parent
+               // When it is an answer, we inherit the receivers from the parent
                $replyto = JsonLD::fetchElement($activity, 'as:inReplyTo', '@id');
                if (!empty($replyto)) {
                        $reply = [$replyto];
@@ -1085,14 +1085,6 @@ class Receiver
                        $reply[] = $object_id;
                }
 
-               if (!empty($reply)) {
-                       $parents = Post::select(['uid'], DBA::mergeConditions(['uri' => $reply], ["`uid` != ?", 0]));
-                       while ($parent = Post::fetch($parents)) {
-                               $receivers[$parent['uid']] = ['uid' => $parent['uid'], 'type' => self::TARGET_ANSWER];
-                       }
-                       DBA::close($parents);
-               }
-
                if (!empty($actor)) {
                        $profile   = APContact::getByURL($actor);
                        $followers = $profile['followers'] ?? '';
@@ -1178,6 +1170,14 @@ class Receiver
                        }
                }
 
+               if (!empty($reply) && (!empty($receivers[0]) || !empty($receivers[-1]))) {
+                       $parents = Post::select(['uid'], DBA::mergeConditions(['uri' => $reply], ["`uid` != ?", 0]));
+                       while ($parent = Post::fetch($parents)) {
+                               $receivers[$parent['uid']] = ['uid' => $parent['uid'], 'type' => self::TARGET_ANSWER];
+                       }
+                       DBA::close($parents);
+               }
+
                self::switchContacts($receivers, $actor);
 
                // "birdsitelive" is a service that mirrors tweets into the fediverse
@@ -1372,7 +1372,7 @@ class Receiver
        /**
         * Fetches the object data from external ressources if needed
         *
-        * @param string  $object_id    Object ID of the the provided object
+        * @param string  $object_id    Object ID of the provided object
         * @param array   $object       The provided object array
         * @param boolean $trust_source Do we trust the provided object?
         * @param integer $uid          User ID for the signature that we use to fetch data