aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Daemon
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Daemon')
-rw-r--r--Zotlabs/Daemon/Content_importer.php14
-rw-r--r--Zotlabs/Daemon/File_importer.php22
2 files changed, 27 insertions, 9 deletions
diff --git a/Zotlabs/Daemon/Content_importer.php b/Zotlabs/Daemon/Content_importer.php
index 72b8e34ce..ff6956051 100644
--- a/Zotlabs/Daemon/Content_importer.php
+++ b/Zotlabs/Daemon/Content_importer.php
@@ -23,7 +23,7 @@ class Content_importer {
$channel = channelx_by_nick($channel_address);
if(! $channel) {
- logger('itemhelper: channel not found');
+ logger('channel not found');
return;
}
@@ -44,7 +44,6 @@ class Content_importer {
}
$j = json_decode($x['body'],true);
-
if (! $j) {
return;
}
@@ -52,8 +51,19 @@ class Content_importer {
if(! is_array($j['item']) || ! count($j['item']))
return;
+ //$total_pages = floor(intval($j['items_total']) / intval($j['items_page']));
+ //logger('importing items: ' . floor((intval($page) * 100) / $total_pages) . '%');
+
+ $saved_notification_flags = notifications_off($channel['channel_id']);
+
import_items($channel,$j['item'],false,((array_key_exists('relocate',$j)) ? $j['relocate'] : null));
+ notifications_on($channel['channel_id'], $saved_notification_flags);
+
+ $page++;
+
+ Master::Summon([ 'Content_importer', sprintf('%d',$page), $since, $until, $channel['channel_address'], urlencode($hz_server) ]);
+
return;
}
}
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;
}