more work on firehose

This commit is contained in:
friendica 2014-03-26 18:45:01 -07:00
parent 150bc9866a
commit ed14c1f224
6 changed files with 44 additions and 10 deletions

View File

@ -29,6 +29,10 @@ function expire_run($argv, $argc){
}
}
$x = get_sys_channel();
if($x)
item_expire($x['channel_id'],30);
return;
}

View File

@ -3767,7 +3767,7 @@ function zot_feed($uid,$observer_xchan,$mindate) {
$r = q("SELECT item.*, item.id as item_id from item
WHERE uid in (" . stream_perms_api_uids(PERMS_PUBLIC) . ") AND item_restrict = 0 and id = parent
AND (item_flags & %d)
$sql_extra ORDER BY created ASC $limit",
and item_private = 0 ORDER BY created ASC $limit",
intval($uid),
intval(ITEM_WALL)
);

View File

@ -167,6 +167,30 @@ function poller_run($argv, $argc){
}
}
// pull in some public posts
$r = q("select site_url from site where site_url != '%s' order by rand() limit 1",
dbesc(z_root())
);
if($r) {
$feedurl = $r[0]['site_url'] . '/zotfeed?f=&mindate=' . urlencode(datetime_convert('','','now - 1 month'));
$x = z_fetch_url($feedurl);
if(($x) && ($x['success'])) {
$total = 0;
$j = json_decode($x['body'],true);
if($j['success'] && $j['messages']) {
require_once('include/identity.php');
$sys = get_sys_channel();
foreach($j['messages'] as $message) {
$results = process_delivery(array('hash' => 'undefined'), get_item_elements($message),
array(array('hash' => $sys['xchan_hash'])), false, true);
$total ++;
}
logger('import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG);
}
}
}
$manual_id = 0;
$generation = 0;

View File

@ -346,9 +346,10 @@ function stream_perms_api_uids($perms_min = PERMS_SITE) {
$ret = array();
if(local_user())
$ret[] = local_user();
$r = q("select channel_id from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d)",
$r = q("select channel_id from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d) and not (channel_pageflags & %d)",
intval($perms_min),
intval(PAGE_CENSORED)
intval(PAGE_CENSORED),
intval(PAGE_SYSTEM)
);
if($r)
foreach($r as $rr)
@ -371,9 +372,10 @@ function stream_perms_xchans($perms_min = PERMS_SITE) {
if(local_user())
$ret[] = get_observer_hash();
$r = q("select channel_hash from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d)",
$r = q("select channel_hash from channel where channel_r_stream > 0 and channel_r_stream <= %d and not (channel_pageflags & %d) and not (channel_pageflags & %d)",
intval($perms_min),
intval(PAGE_CENSORED)
intval(PAGE_CENSORED),
intval(PAGE_SYSTEM)
);
if($r)
foreach($r as $rr)

View File

@ -1354,16 +1354,18 @@ function allowed_public_recips($msg) {
}
function process_delivery($sender,$arr,$deliveries,$relay) {
function process_delivery($sender,$arr,$deliveries,$relay,$public = false) {
$result = array();
// We've validated the sender. Now make sure that the sender is the owner or author
if($sender['hash'] != $arr['owner_xchan'] && $sender['hash'] != $arr['author_xchan']) {
logger("process_delivery: sender {$sender['hash']} is not owner {$arr['owner_xchan']} or author {$arr['author_xchan']} - mid {$arr['mid']}");
return;
if(! $public) {
if($sender['hash'] != $arr['owner_xchan'] && $sender['hash'] != $arr['author_xchan']) {
logger("process_delivery: sender {$sender['hash']} is not owner {$arr['owner_xchan']} or author {$arr['author_xchan']} - mid {$arr['mid']}");
return;
}
}
foreach($deliveries as $d) {
@ -1394,7 +1396,7 @@ function process_delivery($sender,$arr,$deliveries,$relay) {
}
}
if((! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) && (! $tag_delivery)) {
if((! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) && (! $tag_delivery) && (! $public)) {
logger("permission denied for delivery {$channel['channel_id']}");
$result[] = array($d['hash'],'permission denied',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>');
continue;

View File

@ -324,6 +324,8 @@ function dir_parse_query($s) {
function list_public_sites() {
$r = q("select * from site where site_access != 0 and site_register !=0 order by rand()");
$ret = array('success' => false);