]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Delivery.php
Relay code reworked to support AP delivery
[friendica.git] / src / Worker / Delivery.php
index 0a865cb3a7f7047fc5fc8e17a931cbfc5cc984ac..44041957fc428472e56a1df7366e8a566f25fd36 100644 (file)
@@ -33,6 +33,8 @@ use Friendica\Protocol\Activity;
 use Friendica\Util\Strings;
 use Friendica\Util\Network;
 use Friendica\Core\Worker;
+use Friendica\Model\FContact;
+use Friendica\Protocol\Relay;
 
 class Delivery
 {
@@ -58,14 +60,12 @@ class Delivery
                if ($cmd == self::MAIL) {
                        $target_item = DBA::selectFirst('mail', [], ['id' => $target_id]);
                        if (!DBA::isResult($target_item)) {
-                               self::setFailedQueue($cmd, $target_item);
                                return;
                        }
                        $uid = $target_item['uid'];
                } elseif ($cmd == self::SUGGESTION) {
                        $target_item = DBA::selectFirst('fsuggest', [], ['id' => $target_id]);
                        if (!DBA::isResult($target_item)) {
-                               self::setFailedQueue($cmd, $target_item);
                                return;
                        }
                        $uid = $target_item['uid'];
@@ -75,7 +75,6 @@ class Delivery
                } else {
                        $item = Model\Item::selectFirst(['parent'], ['id' => $target_id]);
                        if (!DBA::isResult($item) || empty($item['parent'])) {
-                               self::setFailedQueue($cmd, $target_item);
                                return;
                        }
                        $parent_id = intval($item['parent']);
@@ -85,6 +84,10 @@ class Delivery
                        $itemdata = Model\Item::select([], $condition, $params);
 
                        while ($item = Model\Item::fetch($itemdata)) {
+                               if ($item['verb'] == Activity::ANNOUNCE) {
+                                       continue;
+                               }
+       
                                if ($item['id'] == $parent_id) {
                                        $parent = $item;
                                }
@@ -97,7 +100,6 @@ class Delivery
 
                        if (empty($target_item)) {
                                Logger::log('Item ' . $target_id . "wasn't found. Quitting here.");
-                               self::setFailedQueue($cmd, $target_item);
                                return;
                        }
 
@@ -271,7 +273,7 @@ class Delivery
        private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
        {
                // Transmit Diaspora reshares via Diaspora if the Friendica contact support Diaspora
-               if (Diaspora::isReshare($target_item['body']) && !empty(Diaspora::personByHandle($contact['addr'], false))) {
+               if (Diaspora::isReshare($target_item['body']) && !empty(FContact::getByURL($contact['addr'], false))) {
                        Logger::info('Reshare will be transmitted via Diaspora', ['url' => $contact['url'], 'guid' => ($target_item['guid'] ?? '') ?: $target_item['id']]);
                        self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
                        return;
@@ -483,7 +485,7 @@ class Delivery
 
                        // When it is delivered to the public endpoint, we do mark the relay contact for archival as well
                        if ($public_message) {
-                               Diaspora::markRelayForArchival($contact);
+                               Relay::markForArchival($contact);
                        }
 
                        if (empty($contact['contact-type']) || ($contact['contact-type'] != Model\Contact::TYPE_RELAY)) {