streams/Zotlabs/Daemon/Directory.php

55 lines
1.1 KiB
PHP
Raw Normal View History

2016-05-20 02:42:45 +00:00
<?php
namespace Zotlabs\Daemon;
2021-12-02 22:33:36 +00:00
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libzotdir;
2018-07-03 05:43:41 +00:00
use Zotlabs\Lib\Queue;
2022-01-25 01:26:12 +00:00
use Zotlabs\Lib\Channel;
2018-06-01 02:42:13 +00:00
2021-12-03 03:01:39 +00:00
class Directory
{
2016-05-20 02:42:45 +00:00
2021-12-03 03:01:39 +00:00
public static function run($argc, $argv)
{
2016-05-20 02:42:45 +00:00
2021-12-03 03:01:39 +00:00
if ($argc < 2) {
return;
}
2016-05-20 02:42:45 +00:00
2021-12-03 03:01:39 +00:00
$force = false;
$pushall = true;
2016-05-20 02:42:45 +00:00
2021-12-03 03:01:39 +00:00
if ($argc > 2) {
if ($argv[2] === 'force') {
$force = true;
}
if ($argv[2] === 'nopush') {
$pushall = false;
}
}
2016-05-20 02:42:45 +00:00
2021-12-03 03:01:39 +00:00
logger('directory update', LOGGER_DEBUG);
2016-05-20 02:42:45 +00:00
2022-01-25 01:26:12 +00:00
$channel = Channel::from_id($argv[1]);
2021-12-03 03:01:39 +00:00
if (! $channel) {
return;
}
2016-05-20 02:42:45 +00:00
2021-12-03 03:01:39 +00:00
// update the local directory - was optional, but now done regardless
2016-05-20 02:42:45 +00:00
2021-12-03 03:01:39 +00:00
Libzotdir::local_dir_update($argv[1], $force);
2016-05-20 02:42:45 +00:00
2021-12-03 03:01:39 +00:00
q(
"update channel set channel_dirdate = '%s' where channel_id = %d",
dbesc(datetime_convert()),
intval($channel['channel_id'])
);
2016-05-20 02:42:45 +00:00
2021-12-03 03:01:39 +00:00
// Now update all the connections
if ($pushall) {
Run::Summon([ 'Notifier','refresh_all',$channel['channel_id'] ]);
}
}
2016-05-20 02:42:45 +00:00
}