]> git.mxchange.org Git - friendica.git/commitdiff
Prevent loop also when fetching the outbox
authorMichael <heluecht@pirati.ca>
Sun, 18 Jul 2021 16:42:55 +0000 (16:42 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 18 Jul 2021 16:42:55 +0000 (16:42 +0000)
src/Model/APContact.php
src/Protocol/ActivityPub/Transmitter.php

index 1ae34a40a834e162d4bb1f21aa9b1da635e5dc13..e9500f85b89c585dd301a0e54ee3db6f3a54c5c1 100644 (file)
@@ -148,6 +148,19 @@ class APContact
                        $url = $apcontact['url'];
                }
 
+               // Detect multiple fast repeating request to the same address
+               // See https://github.com/friendica/friendica/issues/9303
+               $cachekey = 'apcontact:getByURL:' . $url;
+               $result = DI::cache()->get($cachekey);
+               if (!is_null($result)) {
+                       Logger::notice('Multiple requests for the address', ['url' => $url, 'update' => $update, 'callstack' => System::callstack(20), 'result' => $result]);
+                       if (!empty($fetched_contact)) {
+                               return $fetched_contact;
+                       }
+               } else {
+                       DI::cache()->set($cachekey, System::callstack(20), Duration::FIVE_MINUTES);
+               }
+
                $curlResult = HTTPSignature::fetchRaw($url);
                $failed = empty($curlResult) || empty($curlResult->getBody()) ||
                        (!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410));
@@ -171,16 +184,6 @@ class APContact
                        return $fetched_contact;
                }
 
-               // Detect multiple fast repeating request to the same address
-               // See https://github.com/friendica/friendica/issues/9303
-               $cachekey = 'apcontact:getByURL:' . $url;
-               $result = DI::cache()->get($cachekey);
-               if (!is_null($result)) {
-                       Logger::notice('Multiple requests for the address', ['url' => $url, 'update' => $update, 'callstack' => System::callstack(20), 'result' => $result]);
-               } else {
-                       DI::cache()->set($cachekey, System::callstack(20), Duration::FIVE_MINUTES);
-               }
-
                $apcontact['url'] = $compacted['@id'];
                $apcontact['uuid'] = JsonLD::fetchElement($compacted, 'diaspora:guid', '@value');
                $apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
index a65f85542296cc79a047f33db4b92fcdfde58946..c19dcf0021766b449e6a9d934d9399b18d1fd109 100644 (file)
@@ -235,7 +235,7 @@ class Transmitter
         */
        public static function getOutbox($owner, $page = null, $requester = '')
        {
-               $public_contact = Contact::getIdForURL($owner['url']);
+               $public_contact = Contact::getIdForURL($owner['url'], 0, false);
                $condition = ['uid' => 0, 'contact-id' => $public_contact,
                        'private' => [Item::PUBLIC, Item::UNLISTED]];