aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/deliver.php12
-rw-r--r--include/queue.php25
2 files changed, 32 insertions, 5 deletions
diff --git a/include/deliver.php b/include/deliver.php
index 86fc90b3f..518f1bc44 100644
--- a/include/deliver.php
+++ b/include/deliver.php
@@ -29,6 +29,8 @@ function deliver_run($argv, $argc) {
* If not, reduce the outq_priority.
*/
+ $base = '';
+
$h = parse_url($r[0]['outq_posturl']);
if($h) {
$base = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : '');
@@ -76,10 +78,12 @@ function deliver_run($argv, $argc) {
$result = z_post_url($r[0]['outq_posturl'],$r[0]['outq_msg']);
if($result['success'] && $result['return_code'] < 300) {
logger('deliver: queue post success to ' . $r[0]['outq_posturl'], LOGGER_DEBUG);
- q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' ",
- dbesc(datetime_convert()),
- dbesc($site_url)
- );
+ if($base) {
+ q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' ",
+ dbesc(datetime_convert()),
+ dbesc($base)
+ );
+ }
q("update dreport set status = '%s', dreport_time = '%s' where dreport_queue = '%s' limit 1",
dbesc('accepted for delivery'),
dbesc(datetime_convert()),
diff --git a/include/queue.php b/include/queue.php
index 18c8c5fa2..061f1507d 100644
--- a/include/queue.php
+++ b/include/queue.php
@@ -23,6 +23,9 @@ function queue_run($argv, $argc){
logger('queue: start');
+ // delete all queue items more than 3 days old
+ // but first mark these sites dead if we haven't heard from them in a month
+
$r = q("select outq_posturl from outq where outq_created < %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('3 DAY')
);
@@ -85,15 +88,34 @@ function queue_run($argv, $argc){
return;
foreach($r as $rr) {
+
+ $dresult = null;
+
if(in_array($rr['outq_posturl'],$deadguys))
continue;
+ $base = '';
+ $h = parse_url($rr['outq_posturl']);
+ if($h)
+ $base = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : '');
+
if($rr['outq_driver'] === 'post') {
$result = z_post_url($rr['outq_posturl'],$rr['outq_msg']);
if($result['success'] && $result['return_code'] < 300) {
logger('queue: queue post success to ' . $rr['outq_posturl'], LOGGER_DEBUG);
+ if($base) {
+ q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' ",
+ dbesc(datetime_convert()),
+ dbesc($base)
+ );
+ }
+ q("update dreport set status = '%s', dreport_time = '%s' where dreport_queue = '%s' limit 1",
+ dbesc('accepted for delivery'),
+ dbesc(datetime_convert()),
+ dbesc($rr['outq_hash'])
+ );
$y = q("delete from outq where outq_hash = '%s'",
- dbesc($rr['ouq_hash'])
+ dbesc($rr['outq_hash'])
);
}
else {
@@ -102,6 +124,7 @@ function queue_run($argv, $argc){
dbesc(datetime_convert()),
dbesc($rr['outq_hash'])
);
+ $deadguys[] = $rr['outq_posturl'];
}
continue;
}