mirror of
https://github.com/friendica/friendica
synced 2024-12-23 02:40:17 +00:00
Merge pull request #14531 from annando/ap-delivery
Only transmit via AP if the relayed post is an AP post
This commit is contained in:
commit
f79be879fa
1 changed files with 45 additions and 65 deletions
|
@ -47,7 +47,6 @@ class Notifier
|
||||||
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid]);
|
Logger::info('Invoked', ['cmd' => $cmd, 'target' => $post_uriid, 'sender_uid' => $sender_uid]);
|
||||||
|
|
||||||
$target_id = $post_uriid;
|
$target_id = $post_uriid;
|
||||||
$top_level = false;
|
|
||||||
$recipients = [];
|
$recipients = [];
|
||||||
|
|
||||||
$delivery_contacts_stmt = null;
|
$delivery_contacts_stmt = null;
|
||||||
|
@ -127,8 +126,6 @@ class Notifier
|
||||||
$item['deleted'] = 1;
|
$item['deleted'] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$top_level = $target_item['gravity'] == Item::GRAVITY_PARENT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataById($uid);
|
$owner = User::getOwnerDataById($uid);
|
||||||
|
@ -172,6 +169,7 @@ class Notifier
|
||||||
if (!$target_item['origin'] && $target_item['network'] == Protocol::ACTIVITYPUB) {
|
if (!$target_item['origin'] && $target_item['network'] == Protocol::ACTIVITYPUB) {
|
||||||
$only_ap_delivery = true;
|
$only_ap_delivery = true;
|
||||||
$diaspora_delivery = false;
|
$diaspora_delivery = false;
|
||||||
|
Logger::debug('Only AP Delivery', ['guid' => $target_item['guid'], 'uri-id' => $target_item['uri-id'], 'network' => $target_item['network'], 'parent-network' => $parent['network'], 'thread-parent-network' => $thr_parent['network']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only deliver threaded replies (comment to a comment) to Diaspora
|
// Only deliver threaded replies (comment to a comment) to Diaspora
|
||||||
|
@ -195,33 +193,13 @@ class Notifier
|
||||||
|
|
||||||
// if $parent['wall'] == 1 we will already have the parent message in our array
|
// if $parent['wall'] == 1 we will already have the parent message in our array
|
||||||
// and we will relay the whole lot.
|
// and we will relay the whole lot.
|
||||||
|
|
||||||
$localhost = str_replace('www.', '', DI::baseUrl()->getHost());
|
|
||||||
if (strpos($localhost, ':')) {
|
|
||||||
$localhost = substr($localhost, 0, strpos($localhost, ':'));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Be VERY CAREFUL if you make any changes to the following several lines. Seemingly innocuous changes
|
|
||||||
* have been known to cause runaway conditions which affected several servers, along with
|
|
||||||
* permissions issues.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
$relay_to_owner = false;
|
$relay_to_owner = false;
|
||||||
|
|
||||||
if (!$top_level && ($parent['wall'] == 0) && (stristr($target_item['uri'], $localhost))) {
|
if (($target_item['gravity'] != Item::GRAVITY_PARENT) && !$parent['wall'] && $target_item['origin']) {
|
||||||
$relay_to_owner = true;
|
$relay_to_owner = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// until the 'origin' flag has been in use for several months
|
if (!$target_item['origin'] || $parent['origin']) {
|
||||||
// we will just use it as a fallback test
|
|
||||||
// later we will be able to use it as the primary test of whether or not to relay.
|
|
||||||
|
|
||||||
if (!$target_item['origin']) {
|
|
||||||
$relay_to_owner = false;
|
|
||||||
}
|
|
||||||
if ($parent['origin']) {
|
|
||||||
$relay_to_owner = false;
|
$relay_to_owner = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,6 +323,7 @@ class Notifier
|
||||||
$ap_contacts = $apdelivery['contacts'];
|
$ap_contacts = $apdelivery['contacts'];
|
||||||
$delivery_queue_count += $apdelivery['count'];
|
$delivery_queue_count += $apdelivery['count'];
|
||||||
|
|
||||||
|
if (!$only_ap_delivery) {
|
||||||
if (empty($delivery_contacts_stmt)) {
|
if (empty($delivery_contacts_stmt)) {
|
||||||
$condition = ['id' => $recipients, 'self' => false, 'uid' => [0, $uid],
|
$condition = ['id' => $recipients, 'self' => false, 'uid' => [0, $uid],
|
||||||
'blocked' => false, 'pending' => false, 'archive' => false];
|
'blocked' => false, 'pending' => false, 'archive' => false];
|
||||||
|
@ -391,6 +370,7 @@ class Notifier
|
||||||
|
|
||||||
$contacts = DBA::toArray($delivery_contacts_stmt);
|
$contacts = DBA::toArray($delivery_contacts_stmt);
|
||||||
$delivery_queue_count += self::delivery($cmd, $post_uriid, $sender_uid, $target_item, $parent, $thr_parent, $owner, $batch_delivery, false, $contacts, $ap_contacts, $conversants);
|
$delivery_queue_count += self::delivery($cmd, $post_uriid, $sender_uid, $target_item, $parent, $thr_parent, $owner, $batch_delivery, false, $contacts, $ap_contacts, $conversants);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($target_item)) {
|
if (!empty($target_item)) {
|
||||||
Logger::info('Calling hooks for ' . $cmd . ' ' . $target_id);
|
Logger::info('Calling hooks for ' . $cmd . ' ' . $target_id);
|
||||||
|
|
Loading…
Reference in a new issue