mirror of
https://github.com/friendica/friendica
synced 2024-11-09 22:22:53 +00:00
Merge pull request #7922 from annando/reshare-delivery
Do reshares as native as possible
This commit is contained in:
commit
a4cc22e8fb
3 changed files with 30 additions and 1 deletions
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue