3 function update_queue_time($id) {
4 logger('queue: requeue item ' . $id);
5 q("UPDATE `queue` SET `last` = '%s' WHERE `id` = %d",
6 dbesc(datetime_convert()),
11 function remove_queue_item($id) {
12 logger('queue: remove queue item ' . $id);
13 q("DELETE FROM `queue` WHERE `id` = %d",
18 function was_recently_delayed($cid) {
20 $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
21 and last > UTC_TIMESTAMP() - interval 15 minute limit 1",
24 if(dba::is_result($r))
27 $r = q("select `term-date` from contact where id = %d and `term-date` != '' and `term-date` != '0000-00-00 00:00:00' limit 1",
31 return (dba::is_result($r));
35 function add_to_queue($cid,$network,$msg,$batch = false) {
37 $max_queue = get_config('system','max_contact_queue');
41 $batch_queue = get_config('system','max_batch_queue');
45 $r = q("SELECT COUNT(*) AS `total` FROM `queue` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
46 WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
50 if($batch && ($r[0]['total'] > $batch_queue)) {
51 logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
54 elseif((! $batch) && ($r[0]['total'] > $max_queue)) {
55 logger('add_to_queue: too many queued items for contact ' . $cid . ' - discarding message');
60 q("INSERT INTO `queue` ( `cid`, `network`, `created`, `last`, `content`, `batch`)
61 VALUES ( %d, '%s', '%s', '%s', '%s', %d) ",
64 dbesc(datetime_convert()),
65 dbesc(datetime_convert()),
67 intval(($batch) ? 1: 0)