diff options
author | friendica <info@friendica.com> | 2013-10-28 00:11:44 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-10-28 00:11:44 -0700 |
commit | 1bf6591e1b98ef6704ee1bab72bad7dca7ab301f (patch) | |
tree | 9f97cc5fda66763025e2875cb148fc867b5b0fad /include | |
parent | d389ceed6cc44c54c971da4bb8538850a0fb0672 (diff) | |
download | volse-hubzilla-1bf6591e1b98ef6704ee1bab72bad7dca7ab301f.tar.gz volse-hubzilla-1bf6591e1b98ef6704ee1bab72bad7dca7ab301f.tar.bz2 volse-hubzilla-1bf6591e1b98ef6704ee1bab72bad7dca7ab301f.zip |
implement monthly directory pings
Diffstat (limited to 'include')
-rw-r--r-- | include/directory.php | 16 | ||||
-rw-r--r-- | include/poller.php | 21 |
2 files changed, 34 insertions, 3 deletions
diff --git a/include/directory.php b/include/directory.php index 16f819805..491240a9d 100644 --- a/include/directory.php +++ b/include/directory.php @@ -31,6 +31,12 @@ function directory_run($argv, $argc){ if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) { syncdirs($argv[1]); + q("update channel set channel_dirdate = '%s' where channel_id = %d limit 1", + dbesc(datetime_convert()), + intval($channel['channel_id']) + ); + + // Now update all the connections proc_run('php','include/notifier.php','refresh_all',$channel['channel_id']); return; @@ -53,6 +59,10 @@ function directory_run($argv, $argc){ // re-queue if unsuccessful if(! $z['success']) { + + // FIXME - we aren't updating channel_dirdate if we have to queue + // the directory packet. That means we'll try again on the next poll run. + $hash = random_string(); q("insert into outq ( outq_hash, outq_account, outq_channel, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s' )", @@ -67,6 +77,12 @@ function directory_run($argv, $argc){ dbesc('') ); } + else { + q("update channel set channel_dirdate = '%s' where channel_id = %d limit 1", + dbesc(datetime_convert()), + intval($channel['channel_id']) + ); + } // Now update all the connections diff --git a/include/poller.php b/include/poller.php index 94ca99e54..f3a997913 100644 --- a/include/poller.php +++ b/include/poller.php @@ -21,6 +21,11 @@ function poller_run($argv, $argc){ } } + $interval = intval(get_config('system','poll_interval')); + if(! $interval) + $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval'))); + + logger('poller: start'); // run queue delivery process in the background @@ -38,6 +43,19 @@ function poller_run($argv, $argc){ intval(ACCOUNT_EXPIRED) ); + // Ensure that every channel pings a directory server once a month. This way we can discover + // channels and sites that quietly vanished and prevent the directory from accumulating stale + // or dead entries. + + $r = q("select channel_id from channel where channel_dirdate < UTC_TIMESTAMP() - INTERVAL 30 DAY"); + if($r) { + foreach($r as $rr) { + proc_run('php','include/directory.php',$rr['channel_id']); + if($interval) + @time_sleep_until(microtime(true) + (float) $interval); + } + } + // publish any applicable items that were set to be published in the future // (time travel posts) @@ -134,9 +152,6 @@ function poller_run($argv, $argc){ $force = true; } - $interval = intval(get_config('system','poll_interval')); - if(! $interval) - $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval'))); $sql_extra = (($manual_id) ? " AND abook_id = $manual_id " : ""); |