mirror of
https://github.com/friendica/friendica
synced 2024-12-22 22:00:16 +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,53 +323,55 @@ class Notifier
|
||||||
$ap_contacts = $apdelivery['contacts'];
|
$ap_contacts = $apdelivery['contacts'];
|
||||||
$delivery_queue_count += $apdelivery['count'];
|
$delivery_queue_count += $apdelivery['count'];
|
||||||
|
|
||||||
if (empty($delivery_contacts_stmt)) {
|
if (!$only_ap_delivery) {
|
||||||
$condition = ['id' => $recipients, 'self' => false, 'uid' => [0, $uid],
|
if (empty($delivery_contacts_stmt)) {
|
||||||
'blocked' => false, 'pending' => false, 'archive' => false];
|
$condition = ['id' => $recipients, 'self' => false, 'uid' => [0, $uid],
|
||||||
if (!empty($networks)) {
|
'blocked' => false, 'pending' => false, 'archive' => false];
|
||||||
$condition['network'] = $networks;
|
if (!empty($networks)) {
|
||||||
}
|
$condition['network'] = $networks;
|
||||||
$delivery_contacts_stmt = DBA::select('contact', ['id', 'uri-id', 'addr', 'url', 'network', 'protocol', 'baseurl', 'gsid', 'batch'], $condition);
|
}
|
||||||
}
|
$delivery_contacts_stmt = DBA::select('contact', ['id', 'uri-id', 'addr', 'url', 'network', 'protocol', 'baseurl', 'gsid', 'batch'], $condition);
|
||||||
|
|
||||||
$conversants = [];
|
|
||||||
$batch_delivery = false;
|
|
||||||
|
|
||||||
if ($public_message && !in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION]) && !$followup) {
|
|
||||||
$participants = [];
|
|
||||||
|
|
||||||
if ($diaspora_delivery && !$unlisted) {
|
|
||||||
$batch_delivery = true;
|
|
||||||
|
|
||||||
$participants = DBA::selectToArray('contact', ['batch', 'network', 'protocol', 'baseurl', 'gsid', 'id', 'url', 'name'],
|
|
||||||
["`network` = ? AND `batch` != '' AND `uid` = ? AND `rel` != ? AND NOT `blocked` AND NOT `pending` AND NOT `archive`", Protocol::DIASPORA, $owner['uid'], Contact::SHARING],
|
|
||||||
['group_by' => ['batch', 'network', 'protocol']]);
|
|
||||||
|
|
||||||
// Fetch the participation list
|
|
||||||
// The function will ensure that there are no duplicates
|
|
||||||
$participants = Diaspora::participantsForThread($target_item, $participants);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = [
|
$conversants = [];
|
||||||
'network' => Protocol::DFRN,
|
$batch_delivery = false;
|
||||||
'uid' => $owner['uid'],
|
|
||||||
'self' => false,
|
|
||||||
'blocked' => false,
|
|
||||||
'pending' => false,
|
|
||||||
'archive' => false,
|
|
||||||
'rel' => [Contact::FOLLOWER, Contact::FRIEND]
|
|
||||||
];
|
|
||||||
|
|
||||||
$contacts = DBA::selectToArray('contact', ['id', 'uri-id', 'url', 'addr', 'name', 'network', 'protocol', 'baseurl', 'gsid'], $condition);
|
if ($public_message && !in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION]) && !$followup) {
|
||||||
|
$participants = [];
|
||||||
|
|
||||||
$conversants = array_merge($contacts, $participants);
|
if ($diaspora_delivery && !$unlisted) {
|
||||||
|
$batch_delivery = true;
|
||||||
|
|
||||||
$delivery_queue_count += self::delivery($cmd, $post_uriid, $sender_uid, $target_item, $parent, $thr_parent, $owner, $batch_delivery, true, $conversants, $ap_contacts, []);
|
$participants = DBA::selectToArray('contact', ['batch', 'network', 'protocol', 'baseurl', 'gsid', 'id', 'url', 'name'],
|
||||||
|
["`network` = ? AND `batch` != '' AND `uid` = ? AND `rel` != ? AND NOT `blocked` AND NOT `pending` AND NOT `archive`", Protocol::DIASPORA, $owner['uid'], Contact::SHARING],
|
||||||
|
['group_by' => ['batch', 'network', 'protocol']]);
|
||||||
|
|
||||||
|
// Fetch the participation list
|
||||||
|
// The function will ensure that there are no duplicates
|
||||||
|
$participants = Diaspora::participantsForThread($target_item, $participants);
|
||||||
|
}
|
||||||
|
|
||||||
|
$condition = [
|
||||||
|
'network' => Protocol::DFRN,
|
||||||
|
'uid' => $owner['uid'],
|
||||||
|
'self' => false,
|
||||||
|
'blocked' => false,
|
||||||
|
'pending' => false,
|
||||||
|
'archive' => false,
|
||||||
|
'rel' => [Contact::FOLLOWER, Contact::FRIEND]
|
||||||
|
];
|
||||||
|
|
||||||
|
$contacts = DBA::selectToArray('contact', ['id', 'uri-id', 'url', 'addr', 'name', 'network', 'protocol', 'baseurl', 'gsid'], $condition);
|
||||||
|
|
||||||
|
$conversants = array_merge($contacts, $participants);
|
||||||
|
|
||||||
|
$delivery_queue_count += self::delivery($cmd, $post_uriid, $sender_uid, $target_item, $parent, $thr_parent, $owner, $batch_delivery, true, $conversants, $ap_contacts, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
$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);
|
|
||||||
|
|
||||||
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