aboutsummaryrefslogtreecommitdiffstats
path: root/include/directory.php
diff options
context:
space:
mode:
authorHaakon Meland Eriksen <haakon.eriksen@far.no>2014-06-24 19:34:36 +0200
committerHaakon Meland Eriksen <haakon.eriksen@far.no>2014-06-24 19:34:36 +0200
commitb8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70 (patch)
tree718df6305bcb82c8dcb4b287a7132422e748cdfb /include/directory.php
parentc2d520f1be115fb3cb5da2a35eb10146cecee8aa (diff)
parenta92fb0b04c3e6474ec48faf8e4cc65c382e89d66 (diff)
downloadvolse-hubzilla-b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70.tar.gz
volse-hubzilla-b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70.tar.bz2
volse-hubzilla-b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include/directory.php')
-rw-r--r--include/directory.php80
1 files changed, 63 insertions, 17 deletions
diff --git a/include/directory.php b/include/directory.php
index d1862cb57..60070f7ec 100644
--- a/include/directory.php
+++ b/include/directory.php
@@ -1,4 +1,5 @@
-g<?php
+<?php /** @file */
+
require_once('boot.php');
require_once('include/zot.php');
require_once('include/cli_startup.php');
@@ -9,18 +10,25 @@ function directory_run($argv, $argc){
cli_startup();
- if($argc != 2)
+ if($argc < 2)
return;
+ $force = false;
+ $pushall = true;
+
+ if($argc > 2) {
+ if($argv[2] === 'force')
+ $force = true;
+ if($argv[2] === 'nopush')
+ $pushall = false;
+ }
+
+ logger('directory update', LOGGER_DEBUG);
+
$dirmode = get_config('system','directory_mode');
if($dirmode === false)
$dirmode = DIRECTORY_MODE_NORMAL;
- if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
- syncdirs($argv[1]);
- return;
- }
-
$x = q("select * from channel where channel_id = %d limit 1",
intval($argv[1])
);
@@ -29,26 +37,64 @@ function directory_run($argv, $argc){
$channel = $x[0];
- // is channel profile visible to the public?
- // FIXME - remove dir entry if permission is revoked
- if(! perm_is_allowed($channel['channel_id'],null,'view_profile'))
+ if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
+
+ local_dir_update($argv[1],$force);
+
+ 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
+ if($pushall)
+ proc_run('php','include/notifier.php','refresh_all',$channel['channel_id']);
+
return;
+ }
$directory = find_upstream_directory($dirmode);
+ $url = $directory['url'] . '/post';
- if($directory) {
- $url = $directory['url'];
- }
- else {
- $url = DIRECTORY_FALLBACK_MASTER . '/post';
- }
+ // 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
+ 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_driver, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg )
+ values ( '%s', %d, %d, '%s', '%s', %d, '%s', '%s', '%s', '%s' )",
+ dbesc($hash),
+ intval($channel['channel_account_id']),
+ intval($channel['channel_id']),
+ dbesc('zot'),
+ dbesc($url),
+ intval(1),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc($packet),
+ 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
+ if($pushall)
+ proc_run('php','include/notifier.php','refresh_all',$channel['channel_id']);
+
}
if (array_search(__file__,get_included_files())===0){