aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php57
-rw-r--r--Zotlabs/Lib/Libzot.php12
2 files changed, 60 insertions, 9 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index a6a194045..a795d8590 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -2712,12 +2712,8 @@ class Activity {
}
if ($fetch_parents) {
- // Cache::set($item['mid'], 'json:' . $act->raw);
- App::$cache['fetch_objects'][$item['mid']]['channels'][] = $channel['channel_id'];
- App::$cache['fetch_objects'][$item['mid']]['force'] = intval($force);
-
- //Master::Summon(['Fetchparents', $channel['channel_id'], $observer_hash, $item['mid'], $force]);
- //self::fetch_and_store_parents($channel, $observer_hash, $item, $act, $force);
+ App::$cache['as_fetch_objects'][$item['mid']]['channels'][] = $channel['channel_id'];
+ App::$cache['as_fetch_objects'][$item['mid']]['force'] = intval($force);
return;
}
}
@@ -3699,5 +3695,54 @@ class Activity {
return $arr;
}
+ /**
+ * @brief Prepares the arguments and inititates the Fetchparents or Zotconvo daemon.
+ * @param string $observer
+ *
+ */
+
+ public static function init_background_fetch(string $observer_hash = '') {
+ hz_syslog(print_r(App::$cache, true));
+
+ if (isset(App::$cache['zot_fetch_objects'])) {
+ $channels_str = '';
+
+ foreach (App::$cache['zot_fetch_objects'] as $mid => $info) {
+ $force = $info['force'];
+
+ foreach ($info['channels'] as $c) {
+ if ($channels_str) {
+ $channels_str .= ',';
+ }
+ $channels_str .= $c;
+ }
+
+ Master::Summon(['Zotconvo', $channels_str, $mid, $force]);
+ }
+ }
+
+ if (isset(App::$cache['as_fetch_objects'])) {
+ if (!$observer_hash) {
+ logger('Attempt to initiate Fetchparents daemon without observer');
+ return;
+ }
+
+ $channels_str = '';
+
+ foreach (App::$cache['as_fetch_objects'] as $mid => $info) {
+ $force = $info['force'];
+
+ foreach ($info['channels'] as $c) {
+ if ($channels_str) {
+ $channels_str .= ',';
+ }
+ $channels_str .= $c;
+ }
+
+ Master::Summon(['Fetchparents', $channels_str, $observer_hash, $mid, $force]);
+ }
+ }
+ }
+
}
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 4a327e24f..70ca2d84b 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Lib;
+use App;
use Zotlabs\Web\HTTPSig;
use Zotlabs\Access\Permissions;
use Zotlabs\Access\PermissionLimits;
@@ -1321,6 +1322,9 @@ class Libzot {
if ($result) {
$return = array_merge($return, $result);
}
+
+ Activity::init_background_fetch();
+
return $return;
}
@@ -1672,10 +1676,12 @@ class Libzot {
}
if ($arr['verb'] === 'Announce') {
- Master::Summon(['Fetchparents', $channel['channel_id'], $sender, $arr['mid'], true]);
+ App::$cache['as_fetch_objects'][$arr['mid']]['channels'][] = $channel['channel_id'];
+ App::$cache['as_fetch_objects'][$arr['mid']]['force'] = true;
}
else {
- Master::Summon(['Zotconvo', $channel['channel_id'], $arr['parent_mid']]);
+ App::$cache['zot_fetch_objects'][$arr['mid']]['channels'][] = $channel['channel_id'];
+ App::$cache['zot_fetch_objects'][$arr['mid']]['force'] = false;
}
continue;
@@ -2977,7 +2983,7 @@ class Libzot {
$ret['site']['admin'] = get_config('system', 'admin_email');
$visible_plugins = [];
- if (is_array(\App::$plugins) && count(\App::$plugins)) {
+ if (is_array(App::$plugins) && count(App::$plugins)) {
$r = q("select * from addon where hidden = 0");
if ($r)
foreach ($r as $rr)