Ensure that pokes are always send only via DFRN

This commit is contained in:
Michael 2019-06-06 04:26:02 +00:00
parent 3b0fabcdb7
commit 44a49a8d7d
6 changed files with 23 additions and 11 deletions

View file

@ -40,6 +40,7 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer; use Friendica\Util\Emailer;
use Friendica\Util\Security; use Friendica\Util\Security;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Worker\Delivery;
require_once 'include/items.php'; require_once 'include/items.php';
@ -603,7 +604,7 @@ function item_post(App $a) {
$origin = $_REQUEST['origin']; $origin = $_REQUEST['origin'];
} }
$notify_type = ($toplevel_item_id ? 'comment-new' : 'wall-new'); $notify_type = ($toplevel_item_id ? Delivery::COMMENT : Delivery::POST);
$uri = ($message_id ? $message_id : Item::newURI($api_source ? $profile_uid : $uid, $guid)); $uri = ($message_id ? $message_id : Item::newURI($api_source ? $profile_uid : $uid, $guid));

View file

@ -28,6 +28,7 @@ use Friendica\Util\Network;
use Friendica\Util\Security; use Friendica\Util\Security;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Worker\Delivery;
use Text_LanguageDetect; use Text_LanguageDetect;
class Item extends BaseObject class Item extends BaseObject
@ -1521,7 +1522,7 @@ class Item extends BaseObject
$allow_gid = $item['allow_gid']; $allow_gid = $item['allow_gid'];
$deny_cid = $item['deny_cid']; $deny_cid = $item['deny_cid'];
$deny_gid = $item['deny_gid']; $deny_gid = $item['deny_gid'];
$notify_type = 'wall-new'; $notify_type = Delivery::POST;
} else { } else {
// find the parent and snarf the item id and ACLs // find the parent and snarf the item id and ACLs
// and anything else we need to inherit // and anything else we need to inherit
@ -1558,8 +1559,8 @@ class Item extends BaseObject
$allow_gid = $parent['allow_gid']; $allow_gid = $parent['allow_gid'];
$deny_cid = $parent['deny_cid']; $deny_cid = $parent['deny_cid'];
$deny_gid = $parent['deny_gid']; $deny_gid = $parent['deny_gid'];
$item['wall'] = $parent['wall']; $item['wall'] = $parent['wall'];
$notify_type = 'comment-new'; $notify_type = Delivery::COMMENT;
/* /*
* If the parent is private, force privacy for the entire conversation * If the parent is private, force privacy for the entire conversation
@ -1603,6 +1604,10 @@ class Item extends BaseObject
} }
} }
if (stristr($item['verb'], ACTIVITY_POKE)) {
$notify_type = Delivery::POKE;
}
$item['parent-uri-id'] = ItemURI::getIdByURI($item['parent-uri']); $item['parent-uri-id'] = ItemURI::getIdByURI($item['parent-uri']);
$item['thr-parent-id'] = ItemURI::getIdByURI($item['thr-parent']); $item['thr-parent-id'] = ItemURI::getIdByURI($item['thr-parent']);
@ -1881,11 +1886,13 @@ class Item extends BaseObject
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, $current_post); Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, $current_post);
} elseif ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin'])) { } elseif ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin'])) {
if ($item['gravity'] == GRAVITY_ACTIVITY) { if ($item['gravity'] == GRAVITY_ACTIVITY) {
$cmd = $item['origin'] ? 'activity-new' : 'activity-import'; $cmd = $item['origin'] ? Delivery::ACTIVITY : 'activity-import';
} elseif ($item['gravity'] == GRAVITY_COMMENT) { } elseif ($item['gravity'] == GRAVITY_COMMENT) {
$cmd = $item['origin'] ? 'comment-new' : 'comment-import'; $cmd = $item['origin'] ? Delivery::COMMENT : 'comment-import';
} elseif (!empty($notify_type)) {
$cmd = $notify_type;
} else { } else {
$cmd = 'wall-new'; $cmd = Delivery::POST;
} }
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $cmd, $current_post); Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $cmd, $current_post);

View file

@ -37,6 +37,7 @@ use Friendica\Util\Map;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\XML; use Friendica\Util\XML;
use Friendica\Worker\Delivery;
use SimpleXMLElement; use SimpleXMLElement;
/** /**
@ -2148,9 +2149,9 @@ class Diaspora
continue; continue;
} }
if ($comment['verb'] == ACTIVITY_POST) { if ($comment['verb'] == ACTIVITY_POST) {
$cmd = $comment['self'] ? 'comment-new' : 'comment-import'; $cmd = $comment['self'] ? Delivery::COMMENT : 'comment-import';
} else { } else {
$cmd = $comment['self'] ? 'like' : 'comment-import'; $cmd = $comment['self'] ? Delivery::ACTIVITY : 'activity-import';
} }
Logger::log("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, Logger::DEBUG); Logger::log("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, Logger::DEBUG);
Worker::add(PRIORITY_HIGH, 'Delivery', $cmd, $comment['id'], $contact_id); Worker::add(PRIORITY_HIGH, 'Delivery', $cmd, $comment['id'], $contact_id);

View file

@ -37,6 +37,7 @@ class APDelivery extends BaseObject
} elseif ($cmd == Delivery::SUGGESTION) { } elseif ($cmd == Delivery::SUGGESTION) {
$success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $target_id); $success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $target_id);
} elseif ($cmd == Delivery::RELOCATION) { } elseif ($cmd == Delivery::RELOCATION) {
} elseif ($cmd == Delivery::POKE) {
} elseif ($cmd == Delivery::REMOVAL) { } elseif ($cmd == Delivery::REMOVAL) {
$success = ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox); $success = ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox);
} elseif ($cmd == Delivery::PROFILEUPDATE) { } elseif ($cmd == Delivery::PROFILEUPDATE) {

View file

@ -26,7 +26,9 @@ class Delivery extends BaseObject
const RELOCATION = 'relocate'; const RELOCATION = 'relocate';
const DELETION = 'drop'; const DELETION = 'drop';
const POST = 'wall-new'; const POST = 'wall-new';
const POKE = 'poke';
const COMMENT = 'comment-new'; const COMMENT = 'comment-new';
const ACTIVITY = 'activity-new';
const REMOVAL = 'removeme'; const REMOVAL = 'removeme';
const PROFILEUPDATE = 'profileupdate'; const PROFILEUPDATE = 'profileupdate';

View file

@ -442,7 +442,7 @@ class Notifier
} }
if (in_array($rr['network'], [Protocol::DFRN, Protocol::DIASPORA]) && ($rr['protocol'] == Protocol::ACTIVITYPUB) && if (in_array($rr['network'], [Protocol::DFRN, Protocol::DIASPORA]) && ($rr['protocol'] == Protocol::ACTIVITYPUB) &&
!in_array($cmd, [Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) { !in_array($cmd, [Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION, Delivery::POKE])) {
Logger::info('Contact is Friendica AP, so skipping delivery via legacy DFRN', ['url' => $rr['url']]); Logger::info('Contact is Friendica AP, so skipping delivery via legacy DFRN', ['url' => $rr['url']]);
continue; continue;
} }
@ -482,7 +482,7 @@ class Notifier
} }
if (in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA]) && ($contact['protocol'] == Protocol::ACTIVITYPUB) && if (in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA]) && ($contact['protocol'] == Protocol::ACTIVITYPUB) &&
!in_array($cmd, [Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) { !in_array($cmd, [Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION, Delivery::POKE])) {
Logger::info('Contact is Friendica AP, so skipping delivery via legacy DFRN', ['url' => $contact['url']]); Logger::info('Contact is Friendica AP, so skipping delivery via legacy DFRN', ['url' => $contact['url']]);
continue; continue;
} }