Delivery to non followers
authorMichael <heluecht@pirati.ca>
Wed, 25 Apr 2018 21:55:24 +0000 (21:55 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 25 Apr 2018 21:55:24 +0000 (21:55 +0000)
src/Worker/Delivery.php

index e8c21fb38d5bfc0d870dbba2d46d972755d40e92..efeabae5841f1d2e1bb162e1c3455e05eaeb9a1e 100644 (file)
@@ -168,11 +168,6 @@ class Delivery {
 
                $deliver_status = 0;
 
-               // Transmit via Diaspora if not possible via Friendica
-               if (($item['uid'] == 0) && ($contact['network'] == NETWORK_DFRN)) {
-                       $contact['network'] = NETWORK_DIASPORA;
-               }
-
                logger("Delivering " . $cmd . " followup=$followup - network ".$contact['network']);
 
                switch ($contact['network']) {
@@ -301,10 +296,14 @@ class Delivery {
                        return;
                }
 
-               if (!Queue::wasDelayed($contact['id'])) {
+               if ($items[0]['uid'] == 0) {
+                       $deliver_status = DFRN::transmit($owner, $contact, $atom);
+                       if ($deliver_status < 200) {
+                               // Transmit via Diaspora if not possible via Friendica
+                               self::deliverDiaspora($cmd, $contact, $owner, $target_item, $public_message, $top_level, $followup, false);
+                               return;
+                       }
                        $deliver_status = DFRN::deliver($owner, $contact, $atom);
-               } else {
-                       $deliver_status = -1;
                }
 
                logger('notifier: dfrn_delivery to '.$contact["url"].' with guid '.$target_item["guid"].' returns '.$deliver_status);
@@ -377,6 +376,8 @@ class Delivery {
 
        private static function deliverMail($cmd, $contact, $owner, $target_item)
        {
+               global $a;
+
                if (Config::get('system','dfrn_only')) {
                        return;
                }
@@ -402,7 +403,7 @@ class Delivery {
                        $reply_to = $mailacct['reply_to'];
                }
 
-               $subject  = (($target_item['title']) ? Email::encodeHeader($target_item['title'], 'UTF-8') : L10n::t("\x28no subject\x29"));
+               $subject  = ($target_item['title'] ? Email::encodeHeader($target_item['title'], 'UTF-8') : L10n::t("\x28no subject\x29"));
 
                // only expose our real email address to true friends
 
@@ -445,7 +446,7 @@ class Delivery {
                                $subject = 'Re: ' . $subject;
                        }
                }
-               Email::send($addr, $subject, $headers, $it);
+               Email::send($addr, $subject, $headers, $target_item);
        }
 
        private static function getItemContact($item, $contacts)