temporary feed import/export (public only for the moment) until this is integrated with remote permissions
This commit is contained in:
parent
cf0e960a90
commit
bec7d9f483
@ -4246,3 +4246,45 @@ function fetch_post_tags($items) {
|
|||||||
|
|
||||||
return $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;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -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
|
// fetch some items
|
||||||
// set last updated timestamp
|
// set last updated timestamp
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ function zfinger_init(&$a) {
|
|||||||
$ztarget = ((x($_REQUEST,'target')) ? $_REQUEST['target'] : '');
|
$ztarget = ((x($_REQUEST,'target')) ? $_REQUEST['target'] : '');
|
||||||
$zsig = ((x($_REQUEST,'target_sig')) ? $_REQUEST['target_sig'] : '');
|
$zsig = ((x($_REQUEST,'target_sig')) ? $_REQUEST['target_sig'] : '');
|
||||||
$zkey = ((x($_REQUEST,'key')) ? $_REQUEST['key'] : '');
|
$zkey = ((x($_REQUEST,'key')) ? $_REQUEST['key'] : '');
|
||||||
|
$mindate = ((x($_REQUEST,'mindate')) ? $_REQUEST['mindate'] : '');
|
||||||
|
$feed = ((x($_REQUEST,'feed')) ? intval($_REQUEST['feed']) : 0);
|
||||||
|
|
||||||
if($ztarget) {
|
if($ztarget) {
|
||||||
if((! $zkey) || (! $zsig) || (! rsa_verify($ztarget,base64url_decode($zsig),$zkey))) {
|
if((! $zkey) || (! $zsig) || (! rsa_verify($ztarget,base64url_decode($zsig),$zkey))) {
|
||||||
@ -139,6 +141,11 @@ function zfinger_init(&$a) {
|
|||||||
if($permissions['view_profile'])
|
if($permissions['view_profile'])
|
||||||
$ret['profile'] = $profile;
|
$ret['profile'] = $profile;
|
||||||
|
|
||||||
|
// if($feed && $permissions['view_stream'])
|
||||||
|
// $ret['messages'] = $zot_feed($e['channel_id'],(($ztarget && $zsig)
|
||||||
|
// ? base64url_encode(hash('whirlpool',$ztarget . $zsig,true))
|
||||||
|
// : '' ),$mindate);
|
||||||
|
|
||||||
// array of (verified) hubs this channel uses
|
// array of (verified) hubs this channel uses
|
||||||
|
|
||||||
$ret['locations'] = array();
|
$ret['locations'] = array();
|
||||||
|
35
mod/zotfeed.php
Normal file
35
mod/zotfeed.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('include/items.php');
|
||||||
|
require_once('include/zot.php');
|
||||||
|
|
||||||
|
function zotfeed_init(&$a) {
|
||||||
|
|
||||||
|
$result = array('success' => false);
|
||||||
|
|
||||||
|
$mindate = (($_REQUEST['mindate']) ? datetime_convert('UTC','UTC',$_REQUEST['mindate']) : '');
|
||||||
|
if(! $mindate)
|
||||||
|
$mindate = '0000-00-00 00:00:00';
|
||||||
|
|
||||||
|
if(get_config('system','block_public') && (! get_account_id()) && (! remote_user())) {
|
||||||
|
$result['message'] = 'Public access denied';
|
||||||
|
json_return_and_die($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$channel_address = ((argc() > 1) ? argv(1) : '');
|
||||||
|
if($channel_address) {
|
||||||
|
$r = q("select channel_id from channel where channel_address = '%s' limit 1",
|
||||||
|
dbesc(argv(1))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if(! $r) {
|
||||||
|
$result['message'] = 'Channel not found.';
|
||||||
|
json_return_and_die($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['messages'] = zot_feed($r[0]['channel_id'],$observer['xchan_hash'],$mindate);
|
||||||
|
$result['success'] = true;
|
||||||
|
json_return_and_die($result);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user