aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-01-18 14:08:31 +0000
committerMario <mario@mariovavti.com>2021-01-18 14:08:31 +0000
commit8e5df2dd2282e98d39c6c5e3c7ef51b71f3979b5 (patch)
tree9d879dfa92e03993675a26b2454f8ac80e5fe851 /Zotlabs
parent441525750f9764f3f42a2ed78ee32a2e6f34c523 (diff)
downloadvolse-hubzilla-8e5df2dd2282e98d39c6c5e3c7ef51b71f3979b5.tar.gz
volse-hubzilla-8e5df2dd2282e98d39c6c5e3c7ef51b71f3979b5.tar.bz2
volse-hubzilla-8e5df2dd2282e98d39c6c5e3c7ef51b71f3979b5.zip
more cleanup daemon/externals
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Externals.php53
1 files changed, 26 insertions, 27 deletions
diff --git a/Zotlabs/Daemon/Externals.php b/Zotlabs/Daemon/Externals.php
index a9988a509..b657f9de4 100644
--- a/Zotlabs/Daemon/Externals.php
+++ b/Zotlabs/Daemon/Externals.php
@@ -8,23 +8,22 @@ require_once('include/channel.php');
class Externals {
- static public function run($argc,$argv){
+ static public function run($argc, $argv) {
- $total = 0;
+ $total = 0;
$attempts = 0;
logger('externals: startup', LOGGER_DEBUG);
// pull in some public posts
+ while ($total == 0 && $attempts < 3) {
+ $arr = ['url' => ''];
+ call_hooks('externals_url_select', $arr);
- while($total == 0 && $attempts < 3) {
- $arr = array('url' => '');
- call_hooks('externals_url_select',$arr);
-
- if($arr['url']) {
+ if ($arr['url']) {
$url = $arr['url'];
- }
+ }
else {
$randfunc = db_getfunc('RAND');
@@ -35,36 +34,36 @@ class Externals {
intval(DIRECTORY_MODE_STANDALONE),
intval(SITE_TYPE_ZOT)
);
- if($r)
+ if ($r)
$url = $r[0]['site_url'];
}
$blacklisted = false;
- if(! check_siteallowed($url)) {
+ if (!check_siteallowed($url)) {
logger('blacklisted site: ' . $url);
$blacklisted = true;
}
- $attempts ++;
+ $attempts++;
// make sure we can eventually break out if somebody blacklists all known sites
- if($blacklisted) {
- if($attempts > 20)
+ if ($blacklisted) {
+ if ($attempts > 20)
break;
- $attempts --;
+ $attempts--;
continue;
}
- if($url) {
- if($r[0]['site_pull'] > NULL_DATE)
- $mindate = urlencode(datetime_convert('','',$r[0]['site_pull'] . ' - 1 day'));
+ if ($url) {
+ if ($r[0]['site_pull'] > NULL_DATE)
+ $mindate = urlencode(datetime_convert('', '', $r[0]['site_pull'] . ' - 1 day'));
else {
- $days = get_config('externals','since_days');
- if($days === false)
+ $days = get_config('externals', 'since_days');
+ if ($days === false)
$days = 15;
- $mindate = urlencode(datetime_convert('','','now - ' . intval($days) . ' days'));
+ $mindate = urlencode(datetime_convert('', '', 'now - ' . intval($days) . ' days'));
}
$feedurl = $url . '/zotfeed?f=&mindate=' . $mindate;
@@ -72,22 +71,22 @@ class Externals {
logger('externals: pulling public content from ' . $feedurl, LOGGER_DEBUG);
$x = z_fetch_url($feedurl);
- if(($x) && ($x['success'])) {
+ if (($x) && ($x['success'])) {
q("update site set site_pull = '%s' where site_url = '%s'",
dbesc(datetime_convert()),
dbesc($url)
);
- $j = json_decode($x['body'],true);
- if($j['success'] && $j['messages']) {
+ $j = json_decode($x['body'], true);
+ if ($j['success'] && $j['messages']) {
$sys = get_sys_channel();
- foreach($j['messages'] as $message) {
+ foreach ($j['messages'] as $message) {
// on these posts, clear any route info.
$message['route'] = '';
- $results = process_delivery(array('hash' => 'undefined'), get_item_elements($message),
- array(array('hash' => $sys['xchan_hash'])), false, true);
- $total ++;
+ process_delivery(['hash' => 'undefined'], get_item_elements($message),
+ [['hash' => $sys['xchan_hash']]], false, true);
+ $total++;
}
logger('externals: import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG);
}