aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Daemon/File_importer.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Daemon/File_importer.php')
-rw-r--r--Zotlabs/Daemon/File_importer.php22
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;
}