aboutsummaryrefslogtreecommitdiffstats
path: root/include/onepoll.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/onepoll.php')
-rw-r--r--include/onepoll.php37
1 files changed, 25 insertions, 12 deletions
diff --git a/include/onepoll.php b/include/onepoll.php
index 8b0c5211b..e81d8bcf7 100644
--- a/include/onepoll.php
+++ b/include/onepoll.php
@@ -1,4 +1,4 @@
-<?php
+<?php /** @file */
require_once('boot.php');
require_once('include/cli_startup.php');
@@ -29,17 +29,15 @@ function onepoll_run($argv, $argc){
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 ) OR ( abook_flags = %d ))
AND (( account_flags = %d ) OR ( account_flags = %d )) limit 1",
intval($contact_id),
- intval(ABOOK_FLAG_HIDDEN),
+ intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_UNCONNECTED),
intval(0),
intval(ACCOUNT_OK),
intval(ACCOUNT_UNVERIFIED)
@@ -67,9 +65,9 @@ function onepoll_run($argv, $argc){
logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['xchan_name']}, CONTACT: {$contact['xchan_name']}");
- $last_update = (($contact['abook_updated'] === '0000-00-00 00:00:00')
+ $last_update = ((($contact['abook_updated'] === $contact['abook_created']) || ($contact['abook_updated'] === '0000-00-00 00:00:00'))
? datetime_convert('UTC','UTC','now - 7 days')
- : datetime_convert('UTC','UTC',$contact['abook_updated'])
+ : datetime_convert('UTC','UTC',$contact['abook_updated'] . ' - 2 days')
);
// update permissions
@@ -98,16 +96,31 @@ function onepoll_run($argv, $argc){
return;
if($contact['xchan_connurl']) {
- $feedurl = str_replace('/poco/','/zotfeed/',$channel['xchan_connurl']);
-
- $x = z_fetch_url($feedurl . '?f=$mindate=' . $last_update);
- if($x['success']) {
+ $fetch_feed = true;
+ $x = null;
+
+ if(! ($contact['abook_their_perms'] & PERMS_R_STREAM ))
+ $fetch_feed = false;
+
+ if($fetch_feed) {
+
+ $feedurl = str_replace('/poco/','/zotfeed/',$contact['xchan_connurl']);
+ $x = z_fetch_url($feedurl . '?f=&mindate=' . urlencode($last_update));
+
+ logger('feed_update: ' . print_r($x,true), LOGGER_DATA);
+
+ }
+
+ if(($x) && ($x['success'])) {
$total = 0;
+ logger('onepoll: feed update ' . $contact['xchan_name']);
+
$j = json_decode($x['body'],true);
if($j['success'] && $j['messages']) {
foreach($j['messages'] as $message) {
- $results = process_delivery(array('hash' => $contact['xchan_hash']),$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));
$total ++;
}
logger("onepoll: $total messages processed");