class Queue
{
- function update_queue_time($id)
+ /**
+ * @param string $id id
+ */
+ public static function updateTime($id)
{
logger('queue: requeue item ' . $id);
dba::update('queue', ['last' => datetime_convert()], ['id' => $id]);
}
- function remove_queue_item($id)
+ /**
+ * @param string $id id
+ */
+ public static function removeItem($id)
{
logger('queue: remove queue item ' . $id);
dba::delete('queue', ['id' => $id]);
*
* @return bool The communication with this contact has currently problems
*/
- function was_recently_delayed($cid)
+ public static function wasDelayed($cid)
{
// Are there queue entries that were recently added?
$r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
return $was_delayed;
}
-
- function add_to_queue($cid, $network, $msg, $batch = false)
+ /**
+ * @param string $cid cid
+ * @param string $network network
+ * @param string $msg message
+ * @param boolean $batch batch, default false
+ */
+ public static function add($cid, $network, $msg, $batch = false)
{
$max_queue = Config::get('system', 'max_contact_queue');
WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
intval($cid)
);
+
if (DBM::is_result($r)) {
if ($batch && ($r[0]['total'] > $batch_queue)) {
logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Profile;
+use Friendica\Model\Queue;
use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Util\Crypto;
require_once 'include/items.php';
require_once 'include/bb2diaspora.php';
require_once 'include/datetime.php';
-require_once 'include/queue_fn.php';
/**
* @brief This class contain functions to create and send Diaspora XML files
logger("transmit: ".$logid."-".$guid." ".$dest_url);
- if (!$queue_run && was_recently_delayed($contact["id"])) {
+ if (!$queue_run && Queue::wasDelayed($contact["id"])) {
$return_code = 0;
} else {
if (!intval(Config::get("system", "diaspora_test"))) {
logger("add_to_queue ignored - identical item already in queue");
} else {
// queue message for redelivery
- add_to_queue($contact["id"], NETWORK_DIASPORA, $envelope, $public_batch);
+ Queue::add($contact["id"], NETWORK_DIASPORA, $envelope, $public_batch);
// The message could not be delivered. We mark the contact as "dead"
Contact::markForArchival($contact);
$envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $contact['pubkey'], $public_batch);
if ($spool) {
- add_to_queue($contact['id'], NETWORK_DIASPORA, $envelope, $public_batch);
+ Queue::add($contact['id'], NETWORK_DIASPORA, $envelope, $public_batch);
return true;
} else {
$return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid);
/**
* @file src/Worker/Delivery.php
*/
-
namespace Friendica\Worker;
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\Queue;
use Friendica\Model\User;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Email;
use dba;
-require_once 'include/queue_fn.php';
require_once 'include/html2plain.php';
require_once 'include/datetime.php';
require_once 'include/items.php';
}
}
- if (!was_recently_delayed($contact['id'])) {
- $deliver_status = DFRN::deliver($owner,$contact,$atom);
+ if (!Queue::wasDelayed($contact['id'])) {
+ $deliver_status = DFRN::deliver($owner, $contact, $atom);
} else {
$deliver_status = (-1);
}
if ($deliver_status < 0) {
logger('notifier: delivery failed: queuing message');
- add_to_queue($contact['id'],NETWORK_DFRN,$atom);
+ Queue::add($contact['id'], NETWORK_DFRN, $atom);
// The message could not be delivered. We mark the contact as "dead"
Contact::markForArchival($contact);
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
+use Friendica\Model\Queue;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\PortableContact;
use dba;
require_once 'include/dba.php';
-require_once 'include/queue_fn.php';
require_once 'include/datetime.php';
require_once 'include/items.php';
require_once 'include/bbcode.php';
$contact = dba::selectFirst('contact', [], ['id' => $q_item['cid']]);
if (!DBM::is_result($contact)) {
- remove_queue_item($q_item['id']);
+ Queue::removeItem($q_item['id']);
return;
}
if (!is_null($dead) && $dead) {
logger('queue: skipping known dead url: ' . $contact['notify']);
- update_queue_time($q_item['id']);
+ Queue::updateTime($q_item['id']);
return;
}
if (!is_null($vital) && !$vital) {
logger('queue: skipping dead server: ' . $server);
- update_queue_time($q_item['id']);
+ Queue::updateTime($q_item['id']);
return;
}
}
$user = dba::selectFirst('user', [], ['uid' => $contact['uid']]);
if (!DBM::is_result($user)) {
- remove_queue_item($q_item['id']);
+ Queue::removeItem($q_item['id']);
return;
}
$deliver_status = DFRN::deliver($owner, $contact, $data);
if ($deliver_status == (-1)) {
- update_queue_time($q_item['id']);
+ Queue::updateTime($q_item['id']);
Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_QUARTER_HOUR);
} else {
- remove_queue_item($q_item['id']);
+ Queue::removeItem($q_item['id']);
}
break;
case NETWORK_OSTATUS:
$deliver_status = Salmon::slapper($owner, $contact['notify'], $data);
if ($deliver_status == (-1)) {
- update_queue_time($q_item['id']);
+ Queue::updateTime($q_item['id']);
Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_QUARTER_HOUR);
} else {
- remove_queue_item($q_item['id']);
+ Queue::removeItem($q_item['id']);
}
}
break;
$deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true);
if ($deliver_status == (-1)) {
- update_queue_time($q_item['id']);
+ Queue::updateTime($q_item['id']);
Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_QUARTER_HOUR);
} else {
- remove_queue_item($q_item['id']);
+ Queue::removeItem($q_item['id']);
}
}
break;
call_hooks('queue_deliver', $params);
if ($params['result']) {
- remove_queue_item($q_item['id']);
+ Queue::removeItem($q_item['id']);
} else {
- update_queue_time($q_item['id']);
+ Queue::updateTime($q_item['id']);
}
break;
}