diff options
author | Mario Vavti <mario@mariovavti.com> | 2021-09-29 21:47:12 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2021-09-29 21:47:12 +0200 |
commit | 4ba47698d7d0ef6c799bd0a28045c1d1e49c76f3 (patch) | |
tree | c2f3b62d4b0e1290e27b05de91574310c4f3832c /Zotlabs/Daemon/File_importer.php | |
parent | 5eb79bd51efbd69d297bbd6f46ee9d1583ec694e (diff) | |
download | volse-hubzilla-4ba47698d7d0ef6c799bd0a28045c1d1e49c76f3.tar.gz volse-hubzilla-4ba47698d7d0ef6c799bd0a28045c1d1e49c76f3.tar.bz2 volse-hubzilla-4ba47698d7d0ef6c799bd0a28045c1d1e49c76f3.zip |
revise content import/export part 2
Diffstat (limited to 'Zotlabs/Daemon/File_importer.php')
-rw-r--r-- | Zotlabs/Daemon/File_importer.php | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Zotlabs/Daemon/File_importer.php b/Zotlabs/Daemon/File_importer.php index 883759a39..2be946fc3 100644 --- a/Zotlabs/Daemon/File_importer.php +++ b/Zotlabs/Daemon/File_importer.php @@ -14,7 +14,7 @@ class File_importer { cli_startup(); - $attach_id = $argv[1]; + $page = $argv[1]; $channel_address = $argv[2]; $hz_server = urldecode($argv[3]); @@ -22,28 +22,36 @@ class File_importer { $channel = channelx_by_nick($channel_address); if(! $channel) { - logger('filehelper: channel not found'); + logger('channel not found'); return; } $headers = [ 'X-API-Token' => random_string(), - 'X-API-Request' => $hz_server . '/api/z/1.0/file/export?f=&file_id=' . $attach_id, + 'X-API-Request' => $hz_server . '/api/z/1.0/file/export_page?f=records=1&page=' . $page, 'Host' => $m['host'], - '(request-target)' => 'get /api/z/1.0/file/export?f=&file_id=' . $attach_id, + '(request-target)' => 'get /api/z/1.0/file/export_page?f=records=1&page=' . $page, ]; $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel),true,'sha512'); - $x = z_fetch_url($hz_server . '/api/z/1.0/file/export?f=&file_id=' . $attach_id,false,$redirects,[ 'headers' => $headers ]); + + $x = z_fetch_url($hz_server . '/api/z/1.0/file/export_page?f=records=1&page=' . $page, false, $redirects, [ 'headers' => $headers ]); if(! $x['success']) { logger('no API response',LOGGER_DEBUG); - return; + killme(); } $j = json_decode($x['body'],true); - $r = sync_files($channel,[$j]); + if(! is_array($j[0]['attach']) || ! count($j[0]['attach'])) + return; + + $r = sync_files($channel,$j); + + $page++; + + Master::Summon([ 'File_importer',sprintf('%d',$page), $channel['channel_address'], urlencode($hz_server) ]); return; } |