diff options
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Daemon/Zotconvo.php | 17 | ||||
-rw-r--r-- | Zotlabs/Lib/Activity.php | 57 | ||||
-rw-r--r-- | Zotlabs/Lib/Libzot.php | 12 |
3 files changed, 71 insertions, 15 deletions
diff --git a/Zotlabs/Daemon/Zotconvo.php b/Zotlabs/Daemon/Zotconvo.php index 16e7f113f..188956d26 100644 --- a/Zotlabs/Daemon/Zotconvo.php +++ b/Zotlabs/Daemon/Zotconvo.php @@ -10,21 +10,26 @@ class Zotconvo { logger('Zotconvo invoked: ' . print_r($argv, true)); - if ($argc != 3) { + if ($argc < 3) { return; } - $mid = $argv[2]; - if (!$mid) { + $channels = explode(',', $argv[1]); + if (!$channels) { return; } - $channel = channelx_by_n(intval($argv[1])); - if (!$channel) { + $mid = $argv[2]; + if (!$mid) { return; } - Libzot::fetch_conversation($channel, $mid); + $force = $argv[3] ?? false; + + foreach ($channels as $channel_id) { + $channel = channelx_by_n($channel_id); + Libzot::fetch_conversation($channel, $mid, $force); + } return; 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) |