]> git.mxchange.org Git - friendica.git/commitdiff
Avoid unmarking for archival an empty contact in Protocol\ActivityPub\Receiver
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 24 Nov 2020 22:32:52 +0000 (17:32 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 24 Nov 2020 22:32:52 +0000 (17:32 -0500)
- Address https://github.com/friendica/friendica/issues/9250#issuecomment-733198306

src/Protocol/ActivityPub/Receiver.php

index d1426ff5aef2400b9871e577674f636ba4a9fa9b..af6eb56ceef326e991540aab74a3d1dc41d3fb57 100644 (file)
@@ -99,13 +99,15 @@ class Receiver
                $actor = JsonLD::fetchElement($ldactivity, 'as:actor', '@id');
 
                $apcontact = APContact::getByURL($actor);
-               if (!empty($apcontact) && ($apcontact['type'] == 'Application') && ($apcontact['nick'] == 'relay')) {
+               if (empty($apcontact)) {
+                       Logger::notice('Unable to retrieve AP contact for actor', ['actor' => $actor]);
+               } elseif ($apcontact['type'] == 'Application' && $apcontact['nick'] == 'relay') {
                        self::processRelayPost($ldactivity, $actor);
                        return;
+               } else {
+                       APContact::unmarkForArchival($apcontact);
                }
 
-               APContact::unMarkForArchival($apcontact);
-
                $http_signer = HTTPSignature::getSigner($body, $header);
                if (empty($http_signer)) {
                        Logger::warning('Invalid HTTP signature, message will be discarded.');
@@ -235,7 +237,7 @@ class Receiver
 
                $profile = APContact::getByURL($object_id);
                if (!empty($profile['type'])) {
-                       APContact::unMarkForArchival($profile);
+                       APContact::unmarkForArchival($profile);
                        return 'as:' . $profile['type'];
                }