X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FQueue.php;h=89ec2826270dd04c57fff62af912f8acf4646ff2;hb=f33bd5fc8e5d3cf9462869815e6c68df6fbfa039;hp=3f4a764cee244f14f4aa927b7d4cd5cbfef68acf;hpb=753f92c2340e23f2397f9e5e506004af154a6189;p=friendica.git diff --git a/src/Worker/Queue.php b/src/Worker/Queue.php index 3f4a764cee..89ec282627 100644 --- a/src/Worker/Queue.php +++ b/src/Worker/Queue.php @@ -10,6 +10,7 @@ use Friendica\Core\Config; use Friendica\Core\Worker; use Friendica\Database\DBM; use Friendica\Model\Queue as QueueModel; +use Friendica\Model\PushSubscriber; use Friendica\Protocol\DFRN; use Friendica\Protocol\Diaspora; use Friendica\Protocol\PortableContact; @@ -34,9 +35,9 @@ class Queue logger('filling queue jobs - start'); // Handling the pubsubhubbub requests - Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'PubSubPublish'); + PushSubscriber::requeue(); - $r = dba::inArray(dba::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP()")); + $r = dba::inArray(dba::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP() ORDER BY `batch`, `cid`")); Addon::callHooks('queue_predeliver', $r); @@ -63,6 +64,11 @@ class Queue return; } + if (empty($contact['notify']) || $contact['archive']) { + QueueModel::removeItem($q_item['id']); + return; + } + $dead = Cache::get($cachekey_deadguy . $contact['notify']); if (!is_null($dead) && $dead && !$no_dead_check) { @@ -81,7 +87,7 @@ class Queue logger("Check server " . $server . " (" . $contact["network"] . ")"); $vital = PortableContact::checkServer($server, $contact["network"], true); - Cache::set($cachekey_server . $server, $vital, CACHE_QUARTER_HOUR); + Cache::set($cachekey_server . $server, $vital, CACHE_MINUTE); } if (!is_null($vital) && !$vital) { @@ -109,37 +115,34 @@ class Queue logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); $deliver_status = DFRN::deliver($owner, $contact, $data); - if ($deliver_status == (-1)) { - QueueModel::updateTime($q_item['id']); - Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_QUARTER_HOUR); - } else { + if (($deliver_status >= 200) && ($deliver_status <= 299)) { QueueModel::removeItem($q_item['id']); + } else { + QueueModel::updateTime($q_item['id']); + Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE); } break; case NETWORK_OSTATUS: - if ($contact['notify']) { - logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); - $deliver_status = Salmon::slapper($owner, $contact['notify'], $data); - - if ($deliver_status == (-1)) { - QueueModel::updateTime($q_item['id']); - Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_QUARTER_HOUR); - } else { - QueueModel::removeItem($q_item['id']); - } + logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); + $deliver_status = Salmon::slapper($owner, $contact['notify'], $data); + + if ($deliver_status == -1) { + QueueModel::updateTime($q_item['id']); + Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE); + } else { + QueueModel::removeItem($q_item['id']); } break; case NETWORK_DIASPORA: - if ($contact['notify']) { - logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); - $deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true, 'Queue:' . $q_item['id'], true); - - if ($deliver_status == (-1)) { - QueueModel::updateTime($q_item['id']); - Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_QUARTER_HOUR); - } else { - QueueModel::removeItem($q_item['id']); - } + logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>'); + $deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true, 'Queue:' . $q_item['id'], true); + + if ((($deliver_status >= 200) && ($deliver_status <= 299)) || + ($contact['contact-type'] == ACCOUNT_TYPE_RELAY)) { + QueueModel::removeItem($q_item['id']); + } else { + QueueModel::updateTime($q_item['id']); + Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE); } break; @@ -154,7 +157,7 @@ class Queue } break; } - logger('Deliver status ' . (int) $deliver_status . ' for item ' . $q_item['id'] . ' to ' . $contact['name'] . ' <' . $contact['url'] . '>'); + logger('Deliver status ' . (int)$deliver_status . ' for item ' . $q_item['id'] . ' to ' . $contact['name'] . ' <' . $contact['url'] . '>'); return; }