]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Delivery.php
Merge pull request #7907 from nupplaphil/task/reduce_app_deps
[friendica.git] / src / Worker / Delivery.php
index 541583be5a51512acd02d493cc71f80313a91342..da0c8f2adb4da018364f11cfff755c212a0ec5e2 100644 (file)
@@ -15,6 +15,7 @@ use Friendica\Model;
 use Friendica\Protocol\DFRN;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\Email;
+use Friendica\Protocol\Activity;
 use Friendica\Util\Strings;
 use Friendica\Util\Network;
 use Friendica\Core\Worker;
@@ -250,6 +251,13 @@ class Delivery extends BaseObject
         */
        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))) {
+                       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;
+               }
+
                Logger::info('Deliver ' . (($target_item['guid'] ?? '') ?: $target_item['id']) . ' via DFRN to ' . (($contact['addr'] ?? '') ?: $contact['url']));
 
                if ($cmd == self::MAIL) {
@@ -481,7 +489,7 @@ class Delivery extends BaseObject
         * @param array  $contact     Contact record of the receiver
         * @param array  $owner       Owner record of the sender
         * @param array  $target_item Item record of the content
-        * @param array  $thr_parent  Item record of the thread parent
+        * @param array  $thr_parent  Item record of the direct parent in the thread
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
@@ -490,7 +498,6 @@ class Delivery extends BaseObject
                if (Config::get('system','dfrn_only')) {
                        return;
                }
-               // WARNING: does not currently convert to RFC2047 header encodings, etc.
 
                $addr = $contact['addr'];
                if (!strlen($addr)) {
@@ -501,6 +508,10 @@ class Delivery extends BaseObject
                        return;
                }
 
+               if ($target_item['verb'] != Activity::POST) {
+                       return;
+               }
+
                if (!empty($thr_parent['object'])) {
                        $data = json_decode($thr_parent['object'], true);
                        if (!empty($data['reply_to'])) {
@@ -545,7 +556,7 @@ class Delivery extends BaseObject
                if ($target_item['uri'] !== $target_item['parent-uri']) {
                        $headers .= 'References: <' . Email::iri2msgid($target_item['parent-uri']) . '>';
 
-                       // If Threading is enabled, write down the correct parent
+                       // Export more references on deeper nested threads
                        if (($target_item['thr-parent'] != '') && ($target_item['thr-parent'] != $target_item['parent-uri'])) {
                                $headers .= ' <' . Email::iri2msgid($target_item['thr-parent']) . '>';
                        }
@@ -575,7 +586,7 @@ class Delivery extends BaseObject
 
                Email::send($addr, $subject, $headers, $target_item);
 
-               Model\ItemDeliveryData::incrementQueueFailed($target_item['id']);
+               Model\ItemDeliveryData::incrementQueueDone($target_item['id'], Model\ItemDeliveryData::MAIL);
 
                Logger::info('Delivered via mail', ['guid' => $target_item['guid'], 'to' => $addr, 'subject' => $subject]);
        }