]> git.mxchange.org Git - friendica.git/commitdiff
Preparation for relay posts with DFRN
authorMichael <heluecht@pirati.ca>
Fri, 27 Apr 2018 05:11:52 +0000 (05:11 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 27 Apr 2018 05:11:52 +0000 (05:11 +0000)
src/Protocol/DFRN.php
src/Worker/Delivery.php

index 74975159ea6221db720437b8af13c86f2946fa50..f233f158a97c69e3ee65299db8ad4839a6388011 100644 (file)
@@ -1405,27 +1405,29 @@ class DFRN
        {
                $a = get_app();
 
-               if (empty($contact['addr'])) {
-                       logger('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.');
-                       if (Contact::updateFromProbe($contact['id'])) {
-                               $new_contact = dba::selectFirst('contact', ['addr'], ['id' => $contact['id']]);
-                               $contact['addr'] = $new_contact['addr'];
+               if (!$public_batch) {
+                       if (empty($contact['addr'])) {
+                               logger('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.');
+                               if (Contact::updateFromProbe($contact['id'])) {
+                                       $new_contact = dba::selectFirst('contact', ['addr'], ['id' => $contact['id']]);
+                                       $contact['addr'] = $new_contact['addr'];
+                               }
+
+                               if (empty($contact['addr'])) {
+                                       logger('Unable to find contact handle for ' . $contact['id'] . ' - ' . $contact['url']);
+                                       Contact::markForArchival($contact);
+                                       return -21;
+                               }
                        }
 
-                       if (empty($contact['addr'])) {
-                               logger('Unable to find contact handle for ' . $contact['id'] . ' - ' . $contact['url']);
+                       $fcontact = Diaspora::personByHandle($contact['addr']);
+                       if (empty($fcontact)) {
+                               logger('Unable to find contact details for ' . $contact['id'] . ' - ' . $contact['addr']);
                                Contact::markForArchival($contact);
-                               return -21;
+                               return -22;
                        }
                }
 
-               $fcontact = Diaspora::personByHandle($contact['addr']);
-               if (empty($fcontact)) {
-                       logger('Unable to find contact details for ' . $contact['id'] . ' - ' . $contact['addr']);
-                       Contact::markForArchival($contact);
-                       return -22;
-               }
-
                $envelope = Diaspora::buildMessage($atom, $owner, $contact, $owner['uprvkey'], $fcontact['pubkey'], $public_batch);
 
                // Create the endpoint for public posts. This is some WIP and should later be added to the probing
index 9dbe0eca0a2e2d0617877bd4dee43fec6751174c..d8ab8822439ff6f5c290cf0ae24d51dc14ef0c07 100644 (file)
@@ -269,7 +269,10 @@ class Delivery extends BaseObject {
                // We don't have a relationship with contacts on a public post.
                // Se we transmit with the new method and via Diaspora as a fallback
                if ($items[0]['uid'] == 0) {
-                       $deliver_status = DFRN::transmit($owner, $contact, $atom);
+                       // Transmit in public if it's a relay post
+                       $public_dfrn = ($contact['contact-type'] == ACCOUNT_TYPE_RELAY);
+
+                       $deliver_status = DFRN::transmit($owner, $contact, $atom, $public_dfrn);
                        if (($deliver_status < 200) || ($deliver_status > 299)) {
                                // Transmit via Diaspora if not possible via Friendica
                                self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);