diff options
author | mrjive <mrjive@mrjive.it> | 2015-01-06 15:13:03 +0100 |
---|---|---|
committer | mrjive <mrjive@mrjive.it> | 2015-01-06 15:13:03 +0100 |
commit | b80c218606994032e76805900cb9b340ea132358 (patch) | |
tree | bf625cf4c59bf521e639018399bf1770d116a6a0 /include/onepoll.php | |
parent | aa6d61d3b19cb13c30bf5a1579adefedf0cc9515 (diff) | |
parent | 3185bfe3ca131d471b8fcdc0c94abf1a114486c7 (diff) | |
download | volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.gz volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.bz2 volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.zip |
Merge pull request #1 from friendica/master
test pull request
Diffstat (limited to 'include/onepoll.php')
-rw-r--r-- | include/onepoll.php | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/include/onepoll.php b/include/onepoll.php index e81d8bcf7..095edd095 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -15,12 +15,6 @@ function onepoll_run($argv, $argc){ logger('onepoll: start'); - $manual_id = 0; - $generation = 0; - - $force = false; - $restart = false; - if(($argc > 1) && (intval($argv[1]))) $contact_id = intval($argv[1]); @@ -28,17 +22,19 @@ function onepoll_run($argv, $argc){ logger('onepoll: no contact'); return; } - + $d = datetime_convert(); $contacts = q("SELECT abook.*, xchan.*, account.* FROM abook LEFT JOIN account on abook_account = account_id left join xchan on xchan_hash = abook_xchan where abook_id = %d - AND (( abook_flags & %d ) OR ( abook_flags = %d )) + AND (( abook_flags & %d )>0 OR ( abook_flags = %d )) + AND NOT ( abook_flags & %d )>0 AND (( account_flags = %d ) OR ( account_flags = %d )) limit 1", intval($contact_id), - intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_UNCONNECTED), + intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_UNCONNECTED|ABOOK_FLAG_FEED), intval(0), + intval(ABOOK_FLAG_ARCHIVED|ABOOK_FLAG_BLOCKED|ABOOK_FLAG_IGNORED), intval(ACCOUNT_OK), intval(ACCOUNT_UNVERIFIED) ); @@ -65,28 +61,42 @@ function onepoll_run($argv, $argc){ logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['xchan_name']}, CONTACT: {$contact['xchan_name']}"); - $last_update = ((($contact['abook_updated'] === $contact['abook_created']) || ($contact['abook_updated'] === '0000-00-00 00:00:00')) + $last_update = ((($contact['abook_updated'] === $contact['abook_created']) || ($contact['abook_updated'] === NULL_DATE)) ? datetime_convert('UTC','UTC','now - 7 days') : datetime_convert('UTC','UTC',$contact['abook_updated'] . ' - 2 days') ); + if($contact['xchan_network'] === 'rss') { + logger('onepoll: processing feed ' . $contact['xchan_name'], LOGGER_DEBUG); + handle_feed($importer['channel_id'],$contact_id,$contact['xchan_hash']); + q("update abook set abook_connected = '%s' where abook_id = %d", + dbesc(datetime_convert()), + intval($contact['abook_id']) + ); + return; + } + + if($contact['xchan_network'] !== 'zot') + return; + // update permissions $x = zot_refresh($contact,$importer); $responded = false; - $updated = datetime_convert(); + $updated = datetime_convert(); + $connected = datetime_convert(); if(! $x) { // mark for death by not updating abook_connected, this is caught in include/poller.php - q("update abook set abook_updated = '%s' where abook_id = %d limit 1", + q("update abook set abook_updated = '%s' where abook_id = %d", dbesc($updated), intval($contact['abook_id']) ); } else { - q("update abook set abook_updated = '%s', abook_connected = '%s' where abook_id = %d limit 1", - dbesc($updated), + q("update abook set abook_updated = '%s', abook_connected = '%s' where abook_id = %d", dbesc($updated), + dbesc($connected), intval($contact['abook_id']) ); $responded = true; @@ -105,7 +115,9 @@ function onepoll_run($argv, $argc){ if($fetch_feed) { $feedurl = str_replace('/poco/','/zotfeed/',$contact['xchan_connurl']); - $x = z_fetch_url($feedurl . '?f=&mindate=' . urlencode($last_update)); + $feedurl .= '?f=&mindate=' . urlencode($last_update); + + $x = z_fetch_url($feedurl); logger('feed_update: ' . print_r($x,true), LOGGER_DATA); @@ -120,7 +132,7 @@ function onepoll_run($argv, $argc){ foreach($j['messages'] as $message) { $results = process_delivery(array('hash' => $contact['xchan_hash']), get_item_elements($message), array(array('hash' => $importer['xchan_hash'])), false); - logger('onepoll: feed_update: process_delivery: ' . print_r($results,true)); + logger('onepoll: feed_update: process_delivery: ' . print_r($results,true), LOGGER_DATA); $total ++; } logger("onepoll: $total messages processed"); @@ -129,14 +141,13 @@ function onepoll_run($argv, $argc){ } - // fetch some items - // set last updated timestamp - + // update the poco details for this connection if($contact['xchan_connurl']) { $r = q("SELECT xlink_id from xlink - where xlink_xchan = '%s' and xlink_updated > UTC_TIMESTAMP() - INTERVAL 1 DAY limit 1", - intval($contact['xchan_hash']) + where xlink_xchan = '%s' and xlink_updated > %s - INTERVAL %s limit 1", + intval($contact['xchan_hash']), + db_utcnow(), db_quoteinterval('1 DAY') ); if(! $r) { poco_load($contact['xchan_hash'],$contact['xchan_connurl']); |