From 41f8796ffc557c00b8bd957aba010180ab87d207 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 6 Dec 2019 06:39:50 +0000 Subject: [PATCH] Delivery of reshares --- src/Protocol/ActivityPub/Transmitter.php | 19 ++++++++++++++++++- src/Worker/Delivery.php | 11 +++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 5bb03a8517..0b7784848e 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -363,7 +363,7 @@ class Transmitter } } - if (Config::get('debug', 'total_ap_delivery')) { + if (self::isAnnounce($item) || Config::get('debug', 'total_ap_delivery')) { // Will be activated in a later step $networks = Protocol::FEDERATED; } else { @@ -1423,6 +1423,23 @@ class Transmitter return ['object' => $reshared_item, 'actor' => $profile, 'comment' => $reshared['comment']]; } + /** + * Checks if the provided item array is an announce + * + * @param array $item + * + * @return boolean + */ + public static function isAnnounce($item) + { + $announce = self::getAnnounceArray($item); + if (empty($announce)) { + return false; + } + + return empty($announce['comment']); + } + /** * Creates an activity id for a given contact id * diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index d9a2109ba3..e59ea37aad 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -251,6 +251,17 @@ class Delivery extends BaseObject */ private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup) { +/* + if (Diaspora::isReshare($target_item['body'])) { + // Transmit Diaspora reshares only via Diaspora + self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup); + return; + } + + if (ActivityPub\Transmitter::::isAnnounce($target_item) && getby) { + return; + } +*/ Logger::info('Deliver ' . (($target_item['guid'] ?? '') ?: $target_item['id']) . ' via DFRN to ' . (($contact['addr'] ?? '') ?: $contact['url'])); if ($cmd == self::MAIL) { -- 2.39.5