3 function update_queue_time($id) {
4 logger('queue: requeue item ' . $id);
5 q("UPDATE `queue` SET `last` = '%s' WHERE `id` = %d LIMIT 1",
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 LIMIT 1",
19 function add_to_queue($cid,$network,$msg,$batch = false) {
21 $max_queue = get_config('system','max_contact_queue');
25 $batch_queue = get_config('system','max_batch_queue');
29 $r = q("SELECT COUNT(*) AS `total` FROM `queue` left join `contact` ON `queue`.`cid` = `contact`.`id`
30 WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
34 if($batch && ($r[0]['total'] > $batch_queue)) {
35 logger('add_to_queue: too many queued items for batch server ' . $cid . ' - discarding message');
38 elseif((! $batch) && ($r[0]['total'] > $max_queue)) {
39 logger('add_to_queue: too many queued items for contact ' . $cid . ' - discarding message');
44 q("INSERT INTO `queue` ( `cid`, `network`, `created`, `last`, `content`, `batch`)
45 VALUES ( %d, '%s', '%s', '%s', '%s', %d) ",
48 dbesc(datetime_convert()),
49 dbesc(datetime_convert()),
51 intval(($batch) ? 1: 0)