diff options
-rwxr-xr-x | boot.php | 2 | ||||
-rwxr-xr-x | include/items.php | 27 | ||||
-rw-r--r-- | include/onepoll.php | 24 | ||||
-rw-r--r-- | include/zot.php | 4 | ||||
-rw-r--r-- | mod/follow.php | 6 | ||||
-rw-r--r-- | mod/item.php | 8 | ||||
-rw-r--r-- | mod/network.php | 4 |
7 files changed, 49 insertions, 26 deletions
@@ -1586,7 +1586,7 @@ function get_max_import_size() { function profile_load(&$a, $nickname, $profile = '') { - logger('profile_load: ' . $profile); + logger('profile_load: ' . $nickname . (($profile) ? ' profile: ' . $profile : '')); $user = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($nickname) diff --git a/include/items.php b/include/items.php index 5793a7d66..f8b698a4a 100755 --- a/include/items.php +++ b/include/items.php @@ -552,15 +552,20 @@ function get_item_elements($x) { $arr['created'] = datetime_convert('UTC','UTC',$x['created']); $arr['edited'] = datetime_convert('UTC','UTC',$x['edited']); - $arr['expires'] = ((x($x,'expires') && $x['expires']) - ? datetime_convert('UTC','UTC',$x['expires']) - : '0000-00-00 00:00:00'); if($arr['created'] > datetime_convert()) $arr['created'] = datetime_convert(); if($arr['edited'] > datetime_convert()) $arr['edited'] = datetime_convert(); + $arr['expires'] = ((x($x,'expires') && $x['expires']) + ? datetime_convert('UTC','UTC',$x['expires']) + : '0000-00-00 00:00:00'); + + $arr['commented'] = ((x($x,'commented') && $x['commented']) + ? datetime_convert('UTC','UTC',$x['commented']) + : $arr['created']); + $arr['title'] = (($x['title']) ? htmlentities($x['title'], ENT_COMPAT,'UTF-8',false) : ''); if(mb_strlen($arr['title']) > 255) @@ -714,6 +719,7 @@ function encode_item($item) { $x['created'] = $item['created']; $x['edited'] = $item['edited']; $x['expires'] = $item['expires']; + $x['commented'] = $item['commented']; $x['mimetype'] = $item['mimetype']; $x['title'] = $item['title']; $x['body'] = $item['body']; @@ -1539,8 +1545,8 @@ function item_store($arr,$allow_exec = false) { $arr['owner_xchan'] = ((x($arr,'owner_xchan')) ? notags(trim($arr['owner_xchan'])) : ''); $arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert()); $arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert()); - $arr['expires'] = ((x($arr,'expires') !== false) ? datetime_convert('UTC','UTC',$arr['expires']) : '0000-00-00 00:00:00'); - $arr['commented'] = datetime_convert(); + $arr['expires'] = ((x($arr,'expires') !== false) ? datetime_convert('UTC','UTC',$arr['expires']) : '0000-00-00 00:00:00'); + $arr['commented'] = ((x($arr,'commented') !== false) ? datetime_convert('UTC','UTC',$arr['commented']) : datetime_convert()); $arr['received'] = datetime_convert(); $arr['changed'] = datetime_convert(); $arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : ''); @@ -1777,8 +1783,15 @@ function item_store($arr,$allow_exec = false) { // update the commented timestamp on the parent - q("UPDATE item set commented = '%s', changed = '%s' WHERE id = %d LIMIT 1", - dbesc(datetime_convert()), + q("update item set commented = ( select max(created) from item where parent_mid = '%s' and uid = %d ) + where id = %d limit 1", + dbesc($arr['parent_mid']), + intval($arr['uid']), + intval($parent_id) + ); + + + q("UPDATE item set changed = '%s' WHERE id = %d LIMIT 1", dbesc(datetime_convert()), intval($parent_id) ); diff --git a/include/onepoll.php b/include/onepoll.php index 5e5589228..a821b76cf 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -36,11 +36,12 @@ function onepoll_run($argv, $argc){ $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 ) OR ( abook_flags & %d )) AND (( account_flags = %d ) OR ( account_flags = %d )) limit 1", intval($contact_id), intval(ABOOK_FLAG_HIDDEN), intval(0), + intval(ABOOK_FLAG_PENDING), intval(ACCOUNT_OK), intval(ACCOUNT_UNVERIFIED) ); @@ -67,7 +68,7 @@ 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'] . ' - 2 days') ); @@ -98,12 +99,22 @@ function onepoll_run($argv, $argc){ return; if($contact['xchan_connurl']) { - $feedurl = str_replace('/poco/','/zotfeed/',$contact['xchan_connurl']); - $x = z_fetch_url($feedurl . '?f=&mindate=' . urlencode($last_update)); + $fetch_feed = true; + $x = null; - logger('feed_update: ' . print_r($x,true), LOGGER_DATA); + if(! ($contact['abook_their_perms'] & PERMS_R_STREAM )) + $fetch_feed = false; - if($x['success']) { + 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']); @@ -112,6 +123,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)); $total ++; } logger("onepoll: $total messages processed"); diff --git a/include/zot.php b/include/zot.php index 71f720a6d..018f00ba5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -346,12 +346,12 @@ function zot_refresh($them,$channel = null) { if($z) proc_run('php','include/notifier.php','permission_update',$z[0]['abook_id']); } - $new_connection = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s' order by abook_created desc limit 1", + $new_connection = q("select abook_id, abook_flags from abook where abook_channel = %d and abook_xchan = '%s' order by abook_created desc limit 1", intval($channel['channel_id']), dbesc($x['hash']) ); - if($new_connection && ($their_perms & PERMS_R_STREAM)) + if($new_connection && (! ($new_connection[0]['abook_flags'] & ABOOK_FLAG_PENDING)) && ($their_perms & PERMS_R_STREAM)) proc_run('php','include/onepoll.php',$new_connection[0]['abook_id']); } diff --git a/mod/follow.php b/mod/follow.php index 1d29dab2e..364fe76b9 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -24,6 +24,12 @@ function follow_init(&$a) { info( t('Channel added.') . EOL); + // If we can view their stream, pull in some posts + + if($result['abook']['abook_their_perms'] & PERMS_R_STREAM) + proc_run('php','include/onepoll.php',$result['abook']['abook_id']); + + goaway(z_root() . '/connections/' . $result['abook']['abook_id']); } diff --git a/mod/item.php b/mod/item.php index b564c7545..7eebbe287 100644 --- a/mod/item.php +++ b/mod/item.php @@ -774,14 +774,6 @@ function item_post(&$a) { // NOTREACHED } - // update the commented timestamp on the parent - - q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1", - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($parent) - ); - $page_type = ''; if($webpage & ITEM_WEBPAGE) diff --git a/mod/network.php b/mod/network.php index 81b38a5ae..9ee21dc05 100644 --- a/mod/network.php +++ b/mod/network.php @@ -512,7 +512,7 @@ function network_content(&$a, $update = 0, $load = false) { . "'; var profile_page = " . $a->pager['page'] . ";</script>"; -logger('Search: ' . $search); + $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( '$baseurl' => z_root(), @@ -734,7 +734,7 @@ logger('Search: ' . $search); $o .= alt_pager($a,count($items)); if($load) { - logger('mod_network: load: ' . count($items) . ' items', LOGGER_DATA); +// logger('mod_network: load: ' . count($items) . ' items', LOGGER_DATA); profiler($start,$first,'network parents'); profiler($first,$second,'network children'); |