]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/APDelivery.php
We only need to fetch the content once
[friendica.git] / src / Worker / APDelivery.php
index 22b8c8f0ffd865560ab8fb827f091a3369950399..ce82db249af324d5881d7c98d9a8458c37cf286d 100644 (file)
@@ -5,30 +5,45 @@
 namespace Friendica\Worker;
 
 use Friendica\BaseObject;
+use Friendica\Core\Logger;
+use Friendica\Core\Worker;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Model\Item;
 use Friendica\Util\HTTPSignature;
 
 class APDelivery extends BaseObject
 {
+       /**
+        * @brief Delivers ActivityPub messages
+        *
+        * @param string $cmd
+        * @param integer $item_id
+        * @param string $inbox
+        * @param integer $uid
+        */
        public static function execute($cmd, $item_id, $inbox, $uid)
        {
-               logger('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG);
+               Logger::log('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, Logger::DEBUG);
+
+               $success = true;
 
                if ($cmd == Delivery::MAIL) {
                } elseif ($cmd == Delivery::SUGGESTION) {
+                       $success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $item_id);
                } elseif ($cmd == Delivery::RELOCATION) {
                } elseif ($cmd == Delivery::REMOVAL) {
-                       ActivityPub::transmitProfileDeletion($uid, $inbox);
+                       $success = ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox);
                } elseif ($cmd == Delivery::PROFILEUPDATE) {
-                       ActivityPub::transmitProfileUpdate($uid, $inbox);
+                       $success = ActivityPub\Transmitter::sendProfileUpdate($uid, $inbox);
                } else {
-                       $data = ActivityPub::createActivityFromItem($item_id);
+                       $data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
                        if (!empty($data)) {
-                               HTTPSignature::transmit($data, $inbox, $uid);
+                               $success = HTTPSignature::transmit($data, $inbox, $uid);
                        }
                }
 
-               return;
+               if (!$success) {
+                       Worker::defer();
+               }
        }
 }