From a0674af4169a8c929c89887d4e7796b21ee55a91 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 27 Mar 2014 15:35:29 -0700 Subject: firehose fixes and optimisations. In particular get rid of the unresponsive script warning when trying to load updates (sine they aren't our posts, we can't check for unseen, hence we can't really load updates). Also make the url selection pluggable. --- include/ConversationObject.php | 10 ++++++-- include/conversation.php | 4 ++-- include/externals.php | 54 ++++++++++++++++++++++++++++++++++++++++++ include/poller.php | 25 ++----------------- 4 files changed, 66 insertions(+), 27 deletions(-) create mode 100644 include/externals.php (limited to 'include') diff --git a/include/ConversationObject.php b/include/ConversationObject.php index 103c3664b..d97438a5d 100644 --- a/include/ConversationObject.php +++ b/include/ConversationObject.php @@ -52,8 +52,14 @@ class Conversation extends BaseObject { switch($mode) { case 'network': - $this->profile_owner = local_user(); - $this->writable = true; + if(array_key_exists('firehose',$a->data) && intval($a->data['firehose'])) { + $this->profile_owner = intval($a->data['firehose']); + $this->writable = false; + } + else { + $this->profile_owner = local_user(); + $this->writable = true; + } break; case 'channel': $this->profile_owner = $a->profile['profile_uid']; diff --git a/include/conversation.php b/include/conversation.php index 6a0936a09..eef2635df 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1384,10 +1384,10 @@ function network_tabs() { // tabs $tabs = array( array( - 'label' => t('Public'), + 'label' => t('External'), 'url'=>$a->get_baseurl(true) . '/' . $cmd . '?f=&fh=1' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '') . ((x($_GET,'gid')) ? '&gid=' . $_GET['gid'] : ''), 'sel'=> $public_active, - 'title'=> t('View Public Streams'), + 'title'=> t('Imported public streams'), ), array( diff --git a/include/externals.php b/include/externals.php new file mode 100644 index 000000000..48aeaf6b3 --- /dev/null +++ b/include/externals.php @@ -0,0 +1,54 @@ + ''); + call_hooks('externals_url_select',$arr); + + if($arr['url']) { + $url = $arr['url']; + } + else { + $r = q("select site_url from site where site_url != '%s' order by rand() limit 1", + dbesc(z_root()) + ); + if($r) + $url = $r[0]['site_url']; + } + + if($url) { + $feedurl = $url . '/zotfeed?f=&mindate=' . urlencode(datetime_convert('','','now - 15 days')); + $x = z_fetch_url($feedurl); + + if(($x) && ($x['success'])) { + $total = 0; + $j = json_decode($x['body'],true); + if($j['success'] && $j['messages']) { + $sys = get_sys_channel(); + foreach($j['messages'] as $message) { + $results = process_delivery(array('hash' => 'undefined'), get_item_elements($message), + array(array('hash' => $sys['xchan_hash'])), false, true); + $total ++; + } + logger('import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG); + } + } + } + +} + +if (array_search(__file__,get_included_files())===0){ + externals_run($argv,$argc); + killme(); +} diff --git a/include/poller.php b/include/poller.php index 9b8ac4165..19037ef17 100644 --- a/include/poller.php +++ b/include/poller.php @@ -167,31 +167,10 @@ function poller_run($argv, $argc){ } } - // pull in some public posts - $r = q("select site_url from site where site_url != '%s' order by rand() limit 1", - dbesc(z_root()) - ); + // pull in some public posts + proc_run('php','include/externals.php'); - if($r) { - $feedurl = $r[0]['site_url'] . '/zotfeed?f=&mindate=' . urlencode(datetime_convert('','','now - 15 days')); - $x = z_fetch_url($feedurl); - - if(($x) && ($x['success'])) { - $total = 0; - $j = json_decode($x['body'],true); - if($j['success'] && $j['messages']) { - require_once('include/identity.php'); - $sys = get_sys_channel(); - foreach($j['messages'] as $message) { - $results = process_delivery(array('hash' => 'undefined'), get_item_elements($message), - array(array('hash' => $sys['xchan_hash'])), false, true); - $total ++; - } - logger('import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG); - } - } - } $manual_id = 0; $generation = 0; -- cgit v1.2.3