From e556dfd475afff75ee525f0d3fd4d1dde27075ea Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 Jul 2019 19:13:17 +0000 Subject: [PATCH] Don't deliver nested comments to Diaspora if the previous comment wasn't from Diaspora --- src/Worker/Delivery.php | 15 ++------------- src/Worker/Notifier.php | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 261065ae9a..ab3e3a6e0b 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -185,19 +185,6 @@ class Delivery extends BaseObject self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup); break; - case Protocol::OSTATUS: - // Do not send to otatus if we are not configured to send to public networks - if ($owner['prvnets']) { - break; - } - if (Config::get('system','ostatus_disabled') || Config::get('system','dfrn_only')) { - break; - } - - // There is currently no code here to distribute anything to OStatus. - // This is done in "notifier.php" (See "url_recipients" and "push_notify") - break; - case Protocol::MAIL: self::deliverMail($cmd, $contact, $owner, $target_item); break; @@ -374,6 +361,7 @@ class Delivery extends BaseObject if (Config::get('system', 'dfrn_only') || !Config::get('system', 'diaspora_enabled')) { return; } + if ($cmd == self::MAIL) { Diaspora::sendMail($target_item, $owner, $contact); return; @@ -382,6 +370,7 @@ class Delivery extends BaseObject if ($cmd == self::SUGGESTION) { return; } + if (!$contact['pubkey'] && !$public_message) { return; } diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 7531a639d7..42ad0afb6d 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -149,12 +149,19 @@ class Notifier $delivery_queue_count += self::activityPubDelivery($cmd, $target_item, $parent, $a->queue['priority'], $a->queue['created'], $owner); } - $fields = ['network', 'author-id', 'owner-id']; + $fields = ['network', 'author-id', 'author-link', 'owner-id']; $condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]]; $thr_parent = Item::selectFirst($fields, $condition); Logger::log('GUID: ' . $target_item["guid"] . ': Parent is ' . $parent['network'] . '. Thread parent is ' . $thr_parent['network'], Logger::DEBUG); + // Only deliver threaded replies (comment to a comment) to Diaspora + // when the original comment author does support the Diaspora protocol. + if ($target_item['parent-uri'] != $target_item['thr-parent']) { + $diaspora_delivery = Diaspora::isSupportedByContactUrl($thr_parent['author-link']); + Logger::info('Threaded comment', ['diaspora_delivery' => (int)$diaspora_delivery]); + } + // This is IMPORTANT!!!! // We will only send a "notify owner to relay" or followup message if the referenced post @@ -349,9 +356,11 @@ class Notifier } // It only makes sense to distribute answers to OStatus messages to Friendica and OStatus - but not Diaspora - $networks = [Protocol::OSTATUS, Protocol::DFRN]; + $networks = [Protocol::DFRN]; + } elseif ($diaspora_delivery) { + $networks = [Protocol::DFRN, Protocol::DIASPORA, Protocol::MAIL]; } else { - $networks = [Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA, Protocol::MAIL]; + $networks = [Protocol::DFRN, Protocol::MAIL]; } } else { $public_message = false;