populate some posts when somebody is granted "read stream" permission

This commit is contained in:
friendica 2013-11-17 16:50:32 -08:00
parent 28b0eb9c33
commit 06e0272db8
7 changed files with 34 additions and 6 deletions

View file

@ -3757,6 +3757,7 @@ function fetch_post_tags($items,$link = false) {
function zot_feed($uid,$observer_xchan,$mindate) {
$result = array();
$mindate = datetime_convert('UTC','UTC',$mindate);
if(! $mindate)
@ -3764,10 +3765,14 @@ function zot_feed($uid,$observer_xchan,$mindate) {
$mindate = dbesc($mindate);
logger('zot_feed: ' . $uid);
if(! perm_is_allowed($uid,$observer_xchan,'view_stream')) {
logger('zot_feed: permission denied.');
return $result;
}
require_once('include/security.php');
$sql_extra = item_permissions_sql($uid);
if($mindate != '0000-00-00 00:00:00') {

View file

@ -98,8 +98,11 @@ 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);
$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['success']) {
$total = 0;
logger('onepoll: feed update ' . $contact['xchan_name']);
@ -107,7 +110,7 @@ function onepoll_run($argv, $argc){
$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);
$total ++;
}

View file

@ -117,7 +117,10 @@ function poller_run($argv, $argc){
set_config('system','last_expire_day',$d2);
// Uncomment when expire protocol component is working
// Update - this is not going to happen. We are only going to
// implement per-item expire, not blanket expiration
// proc_run('php','include/expire.php');
proc_run('php','include/cli_suggest.php');

View file

@ -306,6 +306,11 @@ function zot_refresh($them,$channel = null) {
);
if(! $y)
logger('abook update failed');
else {
// if we were just granted read stream permission and didn't have it before, try to pull in some posts
if((! ($r[0]['abook_their_perms'] & PERMS_R_STREAM)) && ($their_perms & PERMS_R_STREAM))
proc_run('php','include/onepoll.php',$r[0]['abook_id']);
}
}
else {
$default_perms = 0;
@ -330,7 +335,6 @@ function zot_refresh($them,$channel = null) {
);
if($y) {
logger("New introduction received for {$channel['channel_name']}");
if($default_perms) {
// send back a permissions update for auto-friend/auto-permissions
@ -342,6 +346,14 @@ 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",
intval($channel['channel_id']),
dbesc($x['hash'])
);
if($new_connection && ($their_perms & PERMS_R_STREAM))
proc_run('php','include/onepoll.php',$new_connection[0]['abook_id']);
}
}
}

View file

@ -133,6 +133,9 @@ function connections_post(&$a) {
// friends in general or this friend in particular aren't hidden)
// and send out a new friend activity
// TODO
// pull in a bit of content if there is any to pull in
proc_run('php','include/onepoll.php',$contact_id);
}
// Refresh the structure in memory with the new data

View file

@ -15,7 +15,7 @@ function follow_init(&$a) {
$confirm = intval($_REQUEST['confirm']);
$result = new_contact($uid,$url,$a->get_channel(),true,$confirm);
if($result['success'] == false) {
if($result['message'])
notice($result['message']);

View file

@ -21,7 +21,7 @@ function zotfeed_init(&$a) {
$channel_address = ((argc() > 1) ? argv(1) : '');
if($channel_address) {
$r = q("select channel_id from channel where channel_address = '%s' limit 1",
$r = q("select channel_id, channel_name from channel where channel_address = '%s' limit 1",
dbesc(argv(1))
);
}
@ -30,6 +30,8 @@ function zotfeed_init(&$a) {
json_return_and_die($result);
}
logger('zotfeed request: ' . $r[0]['channel_name'], LOGGER_DEBUG);
$result['messages'] = zot_feed($r[0]['channel_id'],$observer['xchan_hash'],$mindate);
$result['success'] = true;
json_return_and_die($result);