AP: Debug option to deliver via AP first

This commit is contained in:
Michael 2019-01-30 19:33:08 +00:00
parent 5d43d521d3
commit fc0acd7b1f
3 changed files with 35 additions and 16 deletions

View file

@ -421,9 +421,13 @@ return [
// Must be writable by the ejabberd process. if set then it will prevent the running of multiple processes.
'lockpath' => '',
],
'debug' => [
// ap_inbox_log (Boolean)
// Logs every call to /inbox as a JSON file in Friendica's temporary directory
'ap_inbox_log' => false,
]
'debug' => [
// ap_inbox_log (Boolean)
// Logs every call to /inbox as a JSON file in Friendica's temporary directory
'ap_inbox_log' => false,
// total_ap_delivery (Boolean)
// Deliver via AP to every possible receiver and we suppress the delivery to these contacts with other protocols
'total_ap_delivery' => false,
]
];

View file

@ -325,11 +325,13 @@ class Transmitter
}
}
// Will be activated in a later step
// $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
// For now only send to these contacts:
$networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
if (Config::get('debug', 'total_ap_delivery')) {
// Will be activated in a later step
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
} else {
// For now only send to these contacts:
$networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
}
$data = ['to' => [], 'cc' => [], 'bcc' => []];
@ -473,11 +475,13 @@ class Transmitter
{
$inboxes = [];
// Will be activated in a later step
// $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
// For now only send to these contacts:
$networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
if (Config::get('debug', 'total_ap_delivery')) {
// Will be activated in a later step
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
} else {
// For now only send to these contacts:
$networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
}
$condition = ['uid' => $uid, 'network' => $networks, 'archive' => false, 'pending' => false];

View file

@ -11,6 +11,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\APContact;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Group;
@ -418,12 +419,17 @@ 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', 'name', 'network'], $condition));
$r2 = DBA::toArray(DBA::select('contact', ['id', 'url', 'name', 'network'], $condition));
$r = array_merge($r2, $relay_list);
if (DBA::isResult($r)) {
foreach ($r as $rr) {
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;
}
$conversants[] = $rr['id'];
$delivery_queue_count++;
@ -447,6 +453,11 @@ class Notifier
// delivery loop
while ($contact = DBA::fetch($delivery_contacts_stmt)) {
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;
}
// Don't deliver to Diaspora if it already had been done as batch delivery
if (($contact['network'] == Protocol::DIASPORA) && $batch_delivery) {
Logger::log('Already delivered id ' . $target_id . ' via batch to ' . json_encode($contact), Logger::DEBUG);