Contacts with protocol = AP are now delivered only via AP

This commit is contained in:
Michael 2019-05-11 05:58:22 +00:00
parent 2a2b147758
commit 55557a8f18
3 changed files with 43 additions and 14 deletions

View file

@ -89,7 +89,7 @@ class Notifier
$uid = $target_id;
$condition = ['uid' => $target_id, 'self' => false, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'network', 'batch'], $condition);
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'network', 'protocol', 'batch'], $condition);
} else {
// find ancestors
$condition = ['id' => $target_id, 'visible' => true, 'moderated' => false];
@ -374,7 +374,7 @@ class Notifier
if (!empty($networks)) {
$condition['network'] = $networks;
}
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'network', 'batch'], $condition);
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'network', 'protocol', 'batch'], $condition);
}
$conversants = [];
@ -388,10 +388,11 @@ class Notifier
$relay_list_stmt = DBA::p(
"SELECT
`batch`,
ANY_VALUE(`id`) AS `id`,
ANY_VALUE(`name`) AS `name`,
ANY_VALUE(`network`) AS `network`
`batch`,
ANY_VALUE(`id`) AS `id`,
ANY_VALUE(`name`) AS `name`,
ANY_VALUE(`network`) AS `network`,
ANY_VALUE(`protocol`) AS `protocol`
FROM `contact`
WHERE `network` = ?
AND `batch` != ''
@ -421,7 +422,7 @@ class Notifier
$condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
$r2 = DBA::toArray(DBA::select('contact', ['id', 'url', 'name', 'network'], $condition));
$r2 = DBA::toArray(DBA::select('contact', ['id', 'url', 'name', 'network', 'protocol'], $condition));
$r = array_merge($r2, $relay_list);
@ -432,6 +433,12 @@ class Notifier
continue;
}
if (($rr['network'] == Protocol::DFRN) && ($rr['protocol'] == Protocol::ACTIVITYPUB) &&
!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
Logger::info('Contact is Friendica AP, so skipping delivery via legacy DFRN', ['url' => $rr['url']]);
continue;
}
if (Config::get('debug', 'total_ap_delivery') && !empty($rr['url']) && ($rr['network'] == Protocol::DFRN) && !empty(APContact::getByURL($rr['url'], false))) {
Logger::log('Skipping contact ' . $rr['url'] . ' since it will be delivered via AP', Logger::DEBUG);
continue;
@ -466,6 +473,12 @@ class Notifier
continue;
}
if (($contact['network'] == Protocol::DFRN) && ($contact['protocol'] == Protocol::ACTIVITYPUB) &&
!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) {
Logger::info('Contact is Friendica AP, so skipping delivery via legacy DFRN', ['url' => $contact['url']]);
continue;
}
if (Config::get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) {
Logger::log('Skipping contact ' . $contact['url'] . ' since it will be delivered via AP', Logger::DEBUG);
continue;