authenticate onepoll so we can receive private posts/comments in zotfeed; if local server bypass the network access and invoke zotfeed directly.

This commit is contained in:
zotlabs 2017-04-30 18:24:48 -07:00 committed by Mario Vavti
parent d3fcef43f8
commit 71e508c7cd
2 changed files with 22 additions and 5 deletions

View File

@ -118,13 +118,29 @@ class Onepoll {
if($fetch_feed) { if($fetch_feed) {
$feedurl = str_replace('/poco/','/zotfeed/',$contact['xchan_connurl']); if(strpos($contact['xchan_connurl'],z_root()) === 0) {
$feedurl .= '?f=&mindate=' . urlencode($last_update); // local channel - save a network fetch
$c = channelx_by_hash($contact['xchan_hash']);
if($c) {
$x = [
'success' => true,
'body' => json_encode( [
'success' => true,
'messages' => zot_feed($c['channel_id'], $importer['xchan_hash'], [ 'mindate' => $last_update ])
])
];
}
}
else {
// remote fetch
$x = z_fetch_url($feedurl); $feedurl = str_replace('/poco/','/zotfeed/',$contact['xchan_connurl']);
$feedurl .= '?f=&mindate=' . urlencode($last_update) . '&zid=' . $importer['channel_address'] . '@' . z_root();
$recurse = 0;
$x = z_fetch_url($feedurl, false, $recurse, [ 'session' => true ]);
}
logger('feed_update: ' . print_r($x,true), LOGGER_DATA); logger('feed_update: ' . print_r($x,true), LOGGER_DATA);
} }
if(($x) && ($x['success'])) { if(($x) && ($x['success'])) {

View File

@ -22,6 +22,7 @@ class Zotfeed extends \Zotlabs\Web\Controller {
$observer = \App::get_observer(); $observer = \App::get_observer();
logger('observer: ' . get_observer_hash(), LOGGER_DEBUG);
$channel_address = ((argc() > 1) ? argv(1) : ''); $channel_address = ((argc() > 1) ? argv(1) : '');
if($channel_address) { if($channel_address) {