diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index aebf598912..b28ee4452e 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..da0c8f2adb 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -251,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) { diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 3e4efb5f3c..19bd518856 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -625,6 +625,11 @@ class Notifier return false; } + // We deliver reshares via AP whenever possible + if (ActivityPub\Transmitter::isAnnounce($item)) { + return true; + } + // Skip DFRN when the item will be (forcefully) delivered via AP if (Config::get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) { return true;