aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Daemon/Onepoll.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Daemon/Onepoll.php')
-rw-r--r--Zotlabs/Daemon/Onepoll.php58
1 files changed, 10 insertions, 48 deletions
diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php
index 568745608..d747e65f3 100644
--- a/Zotlabs/Daemon/Onepoll.php
+++ b/Zotlabs/Daemon/Onepoll.php
@@ -23,9 +23,15 @@ class Onepoll {
return;
}
+ $sql_extra = '';
+ $allow_feeds = get_config('system', 'feed_contacts');
+ if(!$allow_feeds) {
+ $sql_extra = ' and abook_feed = 0 ';
+ }
+
$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
+ FROM abook LEFT JOIN account on abook_account = account_id left join xchan on xchan_hash = abook_xchan
+ where abook_id = %d $sql_extra
and abook_pending = 0 and abook_archived = 0 and abook_blocked = 0 and abook_ignored = 0
AND (( account_flags = %d ) OR ( account_flags = %d )) limit 1",
intval($contact_id),
@@ -52,7 +58,6 @@ class Onepoll {
logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['xchan_name']}, CONTACT: {$contact['xchan_name']}");
- // TODO: unused
$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')
@@ -120,7 +125,7 @@ class Onepoll {
if (!$can_send_stream)
$fetch_feed = false;
- if ($fetch_feed) {
+ if ($fetch_feed && $contact['xchan_network'] !== 'zot') {
$max = intval(get_config('system', 'max_imported_posts', 30));
@@ -136,6 +141,7 @@ class Onepoll {
if ($url) {
logger('fetching outbox');
+ $url = $url . '?date_begin=' . urlencode($last_update);
$obj = new ASCollection($url, $importer, 0, $max);
$messages = $obj->get();
if ($messages) {
@@ -154,50 +160,6 @@ class Onepoll {
}
}
- /* if ($fetch_feed) {
-
- if (strpos($contact['xchan_connurl'], z_root()) === 0) {
- // 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
-
- $feedurl = str_replace('/poco/', '/zotfeed/', $contact['xchan_connurl']);
- $feedurl .= '?f=&mindate=' . urlencode($last_update) . '&zid=' . $importer['channel_address'] . '@' . App::get_hostname();
- $recurse = 0;
- $x = z_fetch_url($feedurl, false, $recurse, ['session' => true]);
- }
-
- logger('feed_update: ' . print_r($x, true), LOGGER_DATA);
- }
-
- if (($x) && ($x['success'])) {
- $total = 0;
- logger('onepoll: feed update ' . $contact['xchan_name'] . ' ' . $feedurl);
-
- $j = json_decode($x['body'], true);
- if ($j['success'] && $j['messages']) {
- foreach ($j['messages'] as $message) {
- $results = process_delivery(['hash' => $contact['xchan_hash']], get_item_elements($message),
- [['hash' => $importer['xchan_hash']]], false);
- logger('onepoll: feed_update: process_delivery: ' . print_r($results, true), LOGGER_DATA);
- $total++;
- }
- logger("onepoll: $total messages processed");
- }
- }
- */
-
// update the poco details for this connection
$r = q("SELECT xlink_id from xlink where xlink_xchan = '%s' and xlink_updated > %s - INTERVAL %s and xlink_static = 0 limit 1",
intval($contact['xchan_hash']),