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 {
$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;
}
*/
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`
}
unset($contact['fnetwork']);
+ if (empty($contact['protocol'])) {
+ $contact['protocol'] = $contact['network'];
+ }
+
if (empty($contact['batch']) && !empty($contact['fbatch'])) {
$contact['batch'] = $contact['fbatch'];
}
$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];
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 = [];
$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` != ''
$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);
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;
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;