Merge pull request #7443 from annando/no-diaspora

Delivery comments to Diaspora only if it is useful
This commit is contained in:
Hypolite Petovan 2019-07-28 16:22:52 -04:00 committed by GitHub
commit c290bcb975
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 16 deletions

View file

@ -185,19 +185,6 @@ class Delivery extends BaseObject
self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup); self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
break; break;
case Protocol::OSTATUS:
// Do not send to otatus if we are not configured to send to public networks
if ($owner['prvnets']) {
break;
}
if (Config::get('system','ostatus_disabled') || Config::get('system','dfrn_only')) {
break;
}
// There is currently no code here to distribute anything to OStatus.
// This is done in "notifier.php" (See "url_recipients" and "push_notify")
break;
case Protocol::MAIL: case Protocol::MAIL:
self::deliverMail($cmd, $contact, $owner, $target_item); self::deliverMail($cmd, $contact, $owner, $target_item);
break; break;
@ -374,6 +361,7 @@ class Delivery extends BaseObject
if (Config::get('system', 'dfrn_only') || !Config::get('system', 'diaspora_enabled')) { if (Config::get('system', 'dfrn_only') || !Config::get('system', 'diaspora_enabled')) {
return; return;
} }
if ($cmd == self::MAIL) { if ($cmd == self::MAIL) {
Diaspora::sendMail($target_item, $owner, $contact); Diaspora::sendMail($target_item, $owner, $contact);
return; return;
@ -382,6 +370,7 @@ class Delivery extends BaseObject
if ($cmd == self::SUGGESTION) { if ($cmd == self::SUGGESTION) {
return; return;
} }
if (!$contact['pubkey'] && !$public_message) { if (!$contact['pubkey'] && !$public_message) {
return; return;
} }

View file

@ -149,12 +149,19 @@ class Notifier
$delivery_queue_count += self::activityPubDelivery($cmd, $target_item, $parent, $a->queue['priority'], $a->queue['created'], $owner); $delivery_queue_count += self::activityPubDelivery($cmd, $target_item, $parent, $a->queue['priority'], $a->queue['created'], $owner);
} }
$fields = ['network', 'author-id', 'owner-id']; $fields = ['network', 'author-id', 'author-link', 'owner-id'];
$condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]]; $condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
$thr_parent = Item::selectFirst($fields, $condition); $thr_parent = Item::selectFirst($fields, $condition);
Logger::log('GUID: ' . $target_item["guid"] . ': Parent is ' . $parent['network'] . '. Thread parent is ' . $thr_parent['network'], Logger::DEBUG); Logger::log('GUID: ' . $target_item["guid"] . ': Parent is ' . $parent['network'] . '. Thread parent is ' . $thr_parent['network'], Logger::DEBUG);
// Only deliver threaded replies (comment to a comment) to Diaspora
// when the original comment author does support the Diaspora protocol.
if ($target_item['parent-uri'] != $target_item['thr-parent']) {
$diaspora_delivery = Diaspora::isSupportedByContactUrl($thr_parent['author-link']);
Logger::info('Threaded comment', ['diaspora_delivery' => (int)$diaspora_delivery]);
}
// This is IMPORTANT!!!! // This is IMPORTANT!!!!
// We will only send a "notify owner to relay" or followup message if the referenced post // We will only send a "notify owner to relay" or followup message if the referenced post
@ -349,9 +356,11 @@ class Notifier
} }
// It only makes sense to distribute answers to OStatus messages to Friendica and OStatus - but not Diaspora // It only makes sense to distribute answers to OStatus messages to Friendica and OStatus - but not Diaspora
$networks = [Protocol::OSTATUS, Protocol::DFRN]; $networks = [Protocol::DFRN];
} elseif ($diaspora_delivery) {
$networks = [Protocol::DFRN, Protocol::DIASPORA, Protocol::MAIL];
} else { } else {
$networks = [Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA, Protocol::MAIL]; $networks = [Protocol::DFRN, Protocol::MAIL];
} }
} else { } else {
$public_message = false; $public_message = false;