aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/dir_fns.php13
-rw-r--r--include/directory.php9
-rw-r--r--include/poller.php2
-rw-r--r--include/zot.php15
-rw-r--r--mod/post.php11
-rw-r--r--version.inc2
6 files changed, 33 insertions, 19 deletions
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 74e12c078..c2e614831 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -139,12 +139,15 @@ function update_directory_entry($ud) {
}
+/**
+ * @function local_dir_update($uid,$force)
+ * push local channel updates to a local directory server
+ *
+ */
+function local_dir_update($uid,$force) {
-
-function syncdirs($uid) {
-
- logger('syncdirs', LOGGER_DEBUG);
+ logger('local_dir_update', LOGGER_DEBUG);
$p = q("select channel.channel_hash, channel_address, channel_timezone, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1",
intval($uid)
@@ -222,7 +225,7 @@ function syncdirs($uid) {
}
$ud_hash = random_string() . '@' . get_app()->get_hostname();
- update_modtime($hash,$ud_hash,$p[0]['channel_address'] . '@' . get_app()->get_hostname(),1);
+ update_modtime($hash,$ud_hash,$p[0]['channel_address'] . '@' . get_app()->get_hostname(),(($force) ? (-1) : 1));
}
diff --git a/include/directory.php b/include/directory.php
index 233899e88..794420b6f 100644
--- a/include/directory.php
+++ b/include/directory.php
@@ -13,6 +13,10 @@ function directory_run($argv, $argc){
if($argc < 2)
return;
+ $force = false;
+ if(($argc > 2) && ($argv[2] === 'force'))
+ $force = true;
+
logger('directory update', LOGGER_DEBUG);
$dirmode = get_config('system','directory_mode');
@@ -29,7 +33,8 @@ function directory_run($argv, $argc){
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
- syncdirs($argv[1]);
+
+ local_dir_update($argv[1],$force);
q("update channel set channel_dirdate = '%s' where channel_id = %d limit 1",
dbesc(datetime_convert()),
@@ -53,7 +58,7 @@ function directory_run($argv, $argc){
// ensure the upstream directory is updated
- $packet = zot_build_packet($channel,'refresh');
+ $packet = zot_build_packet($channel,(($force) ? 'force_refresh' : 'refresh'));
$z = zot_zot($url,$packet);
// re-queue if unsuccessful
diff --git a/include/poller.php b/include/poller.php
index 76c82db09..eba765278 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -64,7 +64,7 @@ function poller_run($argv, $argc){
$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'],'ping');
+ proc_run('php','include/directory.php',$rr['channel_id'],'force');
if($interval)
@time_sleep_until(microtime(true) + (float) $interval);
}
diff --git a/include/zot.php b/include/zot.php
index 109744c53..21eef073c 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -79,12 +79,12 @@ function zot_get_hublocs($hash) {
* zot it to the other side
*
* @param array $channel => sender channel structure
- * @param string $type => packet type: one of 'ping', 'pickup', 'purge', 'refresh', 'notify', 'auth_check'
+ * @param string $type => packet type: one of 'ping', 'pickup', 'purge', 'refresh', 'force_refresh', 'notify', 'auth_check'
* @param array $recipients => envelope information, array ( 'guid' => string, 'guid_sig' => string ); empty for public posts
* @param string $remote_key => optional public site key of target hub used to encrypt entire packet
* NOTE: remote_key and encrypted packets are required for 'auth_check' packets, optional for all others
* @param string $secret => random string, required for packets which require verification/callback
- * e.g. 'pickup', 'purge', 'notify', 'auth_check' --- 'ping' and 'refresh' do not require verification
+ * e.g. 'pickup', 'purge', 'notify', 'auth_check'. Packet types 'ping', 'force_refresh', and 'refresh' do not require verification
*
* @returns string json encoded zot packet
*/
@@ -228,7 +228,7 @@ function zot_finger($webbie,$channel,$autofallback = true) {
}
/**
- * @function: zot_refresh($them, $channel = null)
+ * @function: zot_refresh($them, $channel = null, $force = false)
*
* zot_refresh is typically invoked when somebody has changed permissions of a channel and they are notified
* to fetch new permissions via a finger/discovery operation. This may result in a new connection
@@ -251,7 +251,7 @@ function zot_finger($webbie,$channel,$autofallback = true) {
* @returns boolean true if successful, else false
*/
-function zot_refresh($them,$channel = null) {
+function zot_refresh($them,$channel = null, $force = false) {
logger('zot_refresh: them: ' . print_r($them,true), LOGGER_DATA);
if($channel)
@@ -305,7 +305,7 @@ function zot_refresh($them,$channel = null) {
return false;
}
- $x = import_xchan($j);
+ $x = import_xchan($j,(($force) ? (-1) : 1));
if(! $x['success'])
return false;
@@ -524,6 +524,9 @@ function zot_register_hub($arr) {
* @param array $arr => json_decoded discovery packet
* @param int $ud_flags
* Determines whether to create a directory update record if any changes occur, default 1 or true
+ * $ud_flags = (-1) indicates a forced refresh where we unconditionally create a directory update record
+ * this typically occurs once a month for each channel as part of a scheduled ping to notify the directory
+ * that the channel still exists
*
* @returns array => 'success' (boolean true or false)
* 'message' (optional error string only if success is false)
@@ -885,7 +888,7 @@ function import_xchan($arr,$ud_flags = 1) {
}
}
- if($changed) {
+ if(($changed) || ($ud_flags == (-1))) {
$guid = random_string() . '@' . get_app()->get_hostname();
update_modtime($xchan_hash,$guid,$arr['address'],$ud_flags);
logger('import_xchan: changed: ' . $what,LOGGER_DEBUG);
diff --git a/mod/post.php b/mod/post.php
index cb0dc8302..919f09a35 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -304,9 +304,9 @@ function post_init(&$a) {
*
* Once decrypted, one will find the normal json_encoded zot message packet.
*
- * Defined packet types are: notify, purge, refresh, auth_check, ping, and pickup
+ * Defined packet types are: notify, purge, refresh, force_refresh, auth_check, ping, and pickup
*
- * Standard packet: (used by notify, purge, refresh, and auth_check)
+ * Standard packet: (used by notify, purge, refresh, force_refresh, and auth_check)
*
* {
* "type": "notify",
@@ -793,10 +793,13 @@ function post_post(&$a) {
}
}
- if($msgtype === 'refresh') {
+ if(($msgtype === 'refresh') || ($msgtype === 'force_refresh')) {
// remote channel info (such as permissions or photo or something)
// has been updated. Grab a fresh copy and sync it.
+ // The difference between refresh and force_refresh is that
+ // force_refresh unconditionally creates a directory update record,
+ // even if no changes were detected upon processing.
if($recipients) {
@@ -814,7 +817,7 @@ function post_post(&$a) {
'xchan_guid' => $sender['guid'],
'xchan_guid_sig' => $sender['guid_sig'],
'hubloc_url' => $sender['url']
- ),$r[0]);
+ ),$r[0], (($msgtype === 'force_refresh') ? true : false));
}
}
else {
diff --git a/version.inc b/version.inc
index 177a8cfe6..8b63ff8da 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2014-02-10.584
+2014-02-11.585