diff options
Diffstat (limited to 'include')
-rwxr-xr-x | include/items.php | 42 | ||||
-rw-r--r-- | include/onepoll.php | 19 |
2 files changed, 61 insertions, 0 deletions
diff --git a/include/items.php b/include/items.php index 432f26804..6192de108 100755 --- a/include/items.php +++ b/include/items.php @@ -4246,3 +4246,45 @@ function fetch_post_tags($items) { return $items; } + + + +function zot_feed($uid,$observer,$mindate) { + + $result = array(); + $mindate = datetime_convert('UTC','UTC',$mindate); + if(! $mindate) + $mindate = '0000-00-00 00:00:00'; + + if(! perm_is_allowed($uid,$observer,'view_stream')) { + return $result; + } + +// FIXME +// $sql_extra = item_permissions_sql($r[0]['channel_id'],$remote_contact,$groups); + + if($mindate != '0000-00-00 00:00:00') + $sql_extra .= " and created > '$mindate' "; + + $limit = 200; + + $items = q("SELECT item.* from item + WHERE uid = %d AND item_restrict = 0 + AND (item_flags & %d) + $sql_extra ORDER BY created DESC limit 0, $limit", + intval($uid), + intval(ITEM_WALL) + ); + if($items) { + xchan_query($items); + $items = fetch_post_tags($items); + } else { + $items = array(); + } + + foreach($items as $item) + $result[] = encode_item($item); + + return $result; + +} diff --git a/include/onepoll.php b/include/onepoll.php index a2b3f7a9f..e2636d84a 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -90,6 +90,25 @@ function onepoll_run($argv, $argc){ } + if($contact['xchan_connurl']) { + $feedurl = str_replace('/poco/','/zotfeed/',$channel['xchan_connurl']); + + $x = z_fetch_url($feedurl . '?f=$mindate=' . $last_update); + if($x['success']) { + $total = 0; + $j = json_decode($x['body'],); + if($j['success'] && $j['messages']) { + foreach($j['messages'] as $message) { + $results = process_delivery(array('hash' => $contact['xchan_hash']),$message, + array(array('hash' => $importer['xchan_hash'])), false); + $total ++; + } + logger("onepoll: $total messages processed"); + } + } + } + + // fetch some items // set last updated timestamp |