api_zot: implement /api/z/1.0/network/stream and fix /api/z/1.0/channel/stream
This commit is contained in:
parent
e1ffacbe32
commit
df23ef36c7
@ -11,7 +11,11 @@ api/z/1.0/channel/export/basic
|
||||
|
||||
api/z/1.0/channel/stream
|
||||
|
||||
Fetch conversation items
|
||||
Fetch channel conversation items
|
||||
|
||||
api/z/1.0/network/stream
|
||||
|
||||
Fetch network conversation items
|
||||
|
||||
|
||||
api/z/1.0/files
|
||||
|
@ -33,6 +33,7 @@
|
||||
api_register_func('api/red/item/full','red_item', true);
|
||||
api_register_func('api/z/1.0/item/full','red_item', true);
|
||||
|
||||
api_register_func('api/z/1.0/network/stream','api_network_stream', true);
|
||||
api_register_func('api/z/1.0/abook','api_zot_abook_xchan',true);
|
||||
api_register_func('api/z/1.0/abconfig','api_zot_abconfig',true);
|
||||
api_register_func('api/z/1.0/perm_allowed','api_zot_perm_allowed',true);
|
||||
@ -55,18 +56,63 @@
|
||||
}
|
||||
|
||||
|
||||
function api_network_stream($type) {
|
||||
if(api_user() === false) {
|
||||
logger('api_channel_stream: no user');
|
||||
return false;
|
||||
}
|
||||
|
||||
$channel = channelx_by_n(api_user());
|
||||
if(! $channel)
|
||||
return false;
|
||||
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
// json_return_and_die(post_activity_item($_REQUEST));
|
||||
}
|
||||
else {
|
||||
$mindate = (($_REQUEST['mindate']) ? datetime_convert('UTC','UTC',$_REQUEST['mindate']) : '');
|
||||
if(! $mindate)
|
||||
$mindate = datetime_convert('UTC','UTC', 'now - 14 days');
|
||||
|
||||
$arr = $_REQUEST;
|
||||
$ret = [];
|
||||
$i = items_fetch($arr,App::get_channel(),get_observer_hash());
|
||||
if($i) {
|
||||
foreach($i as $iv) {
|
||||
$ret[] = encode_item($iv);
|
||||
}
|
||||
}
|
||||
|
||||
json_return_and_die($ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function api_channel_stream($type) {
|
||||
if(api_user() === false) {
|
||||
logger('api_channel_stream: no user');
|
||||
return false;
|
||||
}
|
||||
|
||||
$channel = channelx_by_n(api_user());
|
||||
if(! $channel)
|
||||
return false;
|
||||
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
json_return_and_die(post_activity_item($_REQUEST));
|
||||
}
|
||||
else {
|
||||
// fetch stream
|
||||
$mindate = (($_REQUEST['mindate']) ? datetime_convert('UTC','UTC',$_REQUEST['mindate']) : '');
|
||||
if(! $mindate)
|
||||
$mindate = datetime_convert('UTC','UTC', 'now - 14 days');
|
||||
|
||||
json_return_and_die(zot_feed($channel['channel_id'],$channel['channel_hash'],[ 'mindate' => $mindate ]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3980,8 +3980,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
|
||||
|
||||
$sql_nets .= "( abook.abook_closeness >= " . intval($arr['cmin']) . " ";
|
||||
$sql_nets .= " AND abook.abook_closeness <= " . intval($arr['cmax']) . " ) ";
|
||||
/** @fixme dead code, $cmax is undefined */
|
||||
if ($cmax == 99)
|
||||
|
||||
if ($arr['cmax'] == 99)
|
||||
$sql_nets .= " OR abook.abook_closeness IS NULL ) ";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user