pull in some posts when we first connect with a new channel (if allowed to) - if not allowed to, do it if that condition changes
This commit is contained in:
parent
772e3795bf
commit
13538cdd21
2
boot.php
2
boot.php
@ -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)
|
||||
|
@ -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)
|
||||
);
|
||||
|
@ -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");
|
||||
|
@ -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']);
|
||||
|
||||
}
|
||||
|
@ -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']);
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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');
|
||||
|
Reference in New Issue
Block a user