Contacts with protocol = AP are now delivered only via AP
This commit is contained in:
parent
2a2b147758
commit
55557a8f18
|
@ -395,16 +395,24 @@ class Transmitter
|
|||
foreach ($terms as $term) {
|
||||
$cid = Contact::getIdForURL($term['url'], $item['uid']);
|
||||
if (!empty($cid) && in_array($cid, $receiver_list)) {
|
||||
$contact = DBA::selectFirst('contact', ['url'], ['id' => $cid, 'network' => $networks]);
|
||||
if (DBA::isResult($contact) && !empty($profile = APContact::getByURL($contact['url'], false))) {
|
||||
$contact = DBA::selectFirst('contact', ['url', 'network', 'protocol'], ['id' => $cid]);
|
||||
if (!DBA::isResult($contact) || (!in_array($contact['network'], $networks) && ($contact['protocol'] != Protocol::ACTIVITYPUB))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($profile = APContact::getByURL($contact['url'], false))) {
|
||||
$data['to'][] = $profile['url'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($receiver_list as $receiver) {
|
||||
$contact = DBA::selectFirst('contact', ['url', 'hidden'], ['id' => $receiver, 'network' => $networks]);
|
||||
if (DBA::isResult($contact) && !empty($profile = APContact::getByURL($contact['url'], false))) {
|
||||
$contact = DBA::selectFirst('contact', ['url', 'hidden', 'network', 'protocol'], ['id' => $receiver]);
|
||||
if (!DBA::isResult($contact) || (!in_array($contact['network'], $networks) && ($contact['protocol'] != Protocol::ACTIVITYPUB))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($profile = APContact::getByURL($contact['url'], false))) {
|
||||
if ($contact['hidden'] || $always_bcc) {
|
||||
$data['bcc'][] = $profile['url'];
|
||||
} else {
|
||||
|
@ -530,14 +538,18 @@ class Transmitter
|
|||
$networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
|
||||
}
|
||||
|
||||
$condition = ['uid' => $uid, 'network' => $networks, 'archive' => false, 'pending' => false];
|
||||
$condition = ['uid' => $uid, 'archive' => false, 'pending' => false];
|
||||
|
||||
if (!empty($uid)) {
|
||||
$condition['rel'] = [Contact::FOLLOWER, Contact::FRIEND];
|
||||
}
|
||||
|
||||
$contacts = DBA::select('contact', ['url'], $condition);
|
||||
$contacts = DBA::select('contact', ['url', 'network', 'protocol'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
if (!in_array($contact['network'], $networks) && ($contact['protocol'] != Protocol::ACTIVITYPUB)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Network::isUrlBlocked($contact['url'])) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ class Diaspora
|
|||
*/
|
||||
public static function participantsForThread($thread, array $contacts)
|
||||
{
|
||||
$r = DBA::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`,
|
||||
$r = DBA::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`, `contact`.`protocol`,
|
||||
`fcontact`.`batch` AS `fbatch`, `fcontact`.`network` AS `fnetwork` FROM `participation`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid`
|
||||
INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid`
|
||||
|
@ -224,6 +224,10 @@ class Diaspora
|
|||
}
|
||||
unset($contact['fnetwork']);
|
||||
|
||||
if (empty($contact['protocol'])) {
|
||||
$contact['protocol'] = $contact['network'];
|
||||
}
|
||||
|
||||
if (empty($contact['batch']) && !empty($contact['fbatch'])) {
|
||||
$contact['batch'] = $contact['fbatch'];
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue