]> git.mxchange.org Git - friendica.git/blobdiff - include/queue_fn.php
Merge branch 'rewrites/dbm_is_result' of github.com:Quix0r/friendica into rewrites...
[friendica.git] / include / queue_fn.php
index a68aa8918fb4ac9fc37e9a3f0949131f3f7f8259..df9ab6b4cbc950f048040486f68f926a27017d5f 100644 (file)
@@ -24,7 +24,12 @@ function remove_queue_item($id) {
  */
 function was_recently_delayed($cid) {
 
-       $was_delayed = false;
+       $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d 
+               and last > UTC_TIMESTAMP() - interval 15 minute limit 1",
+               intval($cid)
+       );
+       if(dbm::is_result($r))
+               return true;
 
        // Are there queue entries that were recently added?
        $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
@@ -32,18 +37,7 @@ function was_recently_delayed($cid) {
                intval($cid)
        );
 
-       $was_delayed = dbm::is_result($r);
-
-       // We set "term-date" to a current date if the communication has problems.
-       // If the communication works again we reset this value.
-       if ($was_delayed) {
-               $r = q("SELECT `term-date` FROM `contact` WHERE `id` = %d AND `term-date` <= '1000-01-01' LIMIT 1",
-                       intval($cid)
-               );
-               $was_delayed = !dbm::is_result($r);
-       }
-
-       return $was_delayed;
+       return (dbm::is_result($r));
 }
 
 
@@ -61,7 +55,7 @@ function add_to_queue($cid,$network,$msg,$batch = false) {
                WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
                intval($cid)
        );
-       if($r && count($r)) {
+       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');
                        return;