Fix delivery counter for poking / unify delivery commands

This commit is contained in:
Michael 2019-06-10 14:19:24 +00:00
parent f5606fb211
commit 41dc243186
16 changed files with 38 additions and 73 deletions

View file

@ -48,7 +48,7 @@ class APDelivery extends BaseObject
$data = ActivityPub\Transmitter::createCachedActivityFromItem($target_id);
if (!empty($data)) {
$success = HTTPSignature::transmit($data, $inbox, $uid);
if ($success && in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
if ($success && in_array($cmd, [Delivery::POST])) {
ItemDeliveryData::incrementQueueDone($target_id);
}
}

View file

@ -27,8 +27,7 @@ class Delivery extends BaseObject
const DELETION = 'drop';
const POST = 'wall-new';
const POKE = 'poke';
const COMMENT = 'comment-new';
const ACTIVITY = 'activity-new';
const UPLINK = 'uplink';
const REMOVAL = 'removeme';
const PROFILEUPDATE = 'profileupdate';
@ -319,7 +318,7 @@ class Delivery extends BaseObject
// We successfully delivered a message, the contact is alive
Model\Contact::unmarkForArchival($contact);
if (in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
Model\ItemDeliveryData::incrementQueueDone($target_item['id']);
}
} else {
@ -400,7 +399,7 @@ class Delivery extends BaseObject
// We successfully delivered a message, the contact is alive
Model\Contact::unmarkForArchival($contact);
if (in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
Model\ItemDeliveryData::incrementQueueDone($target_item['id']);
}
} else {
@ -411,7 +410,7 @@ class Delivery extends BaseObject
Logger::info('Delivery failed: defer message', ['id' => defaults($target_item, 'guid', $target_item['id'])]);
// defer message for redelivery
Worker::defer();
} elseif (in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
} elseif (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
Model\ItemDeliveryData::incrementQueueDone($target_item['id']);
}
}
@ -439,7 +438,7 @@ class Delivery extends BaseObject
return;
}
if (!in_array($cmd, [self::POST, self::COMMENT])) {
if (!in_array($cmd, [self::POST, self::POKE])) {
return;
}

View file

@ -32,23 +32,7 @@ require_once 'include/items.php';
*
* Worker::add(PRIORITY_HIGH, "Notifier", COMMAND, ITEM_ID);
*
* where COMMAND is one of the following:
*
* activity (in diaspora.php, dfrn_confirm.php, profiles.php)
* comment-import (in diaspora.php, items.php)
* comment-new (in item.php)
* drop (in diaspora.php, items.php, photos.php)
* edit_post (in item.php)
* event (in events.php)
* like (in like.php, poke.php)
* mail (in message.php)
* suggest (in fsuggest.php)
* tag (in photos.php, poke.php, tagger.php)
* tgroup (in items.php)
* wall-new (in photos.php, item.php)
* removeme (in Contact.php)
* relocate (in uimport.php)
*
* where COMMAND is one of the constants that are defined in Worker/Delivery.php
* and ITEM_ID is the id of the item in the database that needs to be sent to others.
*/
@ -199,7 +183,7 @@ class Notifier
}
if (($cmd === 'uplink') && (intval($parent['forum_mode']) == 1) && !$top_level) {
if (($cmd === Delivery::UPLINK) && (intval($parent['forum_mode']) == 1) && !$top_level) {
$relay_to_owner = true;
}
@ -287,8 +271,8 @@ class Notifier
// if our parent is a public forum (forum_mode == 1), uplink to the origional author causing
// a delivery fork. private groups (forum_mode == 2) do not uplink
if ((intval($parent['forum_mode']) == 1) && !$top_level && ($cmd !== 'uplink')) {
Worker::add($a->queue['priority'], 'Notifier', 'uplink', $target_id);
if ((intval($parent['forum_mode']) == 1) && !$top_level && ($cmd !== Delivery::UPLINK)) {
Worker::add($a->queue['priority'], 'Notifier', Delivery::UPLINK, $target_id);
}
foreach ($items as $item) {
@ -545,7 +529,7 @@ class Notifier
if (!empty($target_item)) {
Logger::log('Calling hooks for ' . $cmd . ' ' . $target_id, Logger::DEBUG);
if (in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
ItemDeliveryData::update($target_item['id'], ['queue_count' => $delivery_queue_count]);
}