1
1
Fork 0

Merge pull request #4084 from MrPetovan/task/4071-add-networkpublic_timeline-api

Add statuses/networkpublic_timeline api method
This commit is contained in:
Michael Vogel 2017-12-17 16:52:17 +01:00 committed by GitHub
commit 9ff4d2d838
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 0 deletions

View file

@ -338,6 +338,15 @@ Friendica doesn't allow showing the friends of other users.
#### Unsupported parameters
* trim_user
---
### statuses/networkpublic_timeline (*; AUTH)
#### Parameters
* count: Items per page (default: 20)
* page: page number
* since_id: minimum id
* max_id: maximum id
* include_entities: "true" shows entities for pictures and links (Default: false)
---
### statuses/replies (*; AUTH)
#### Parameters

View file

@ -1660,6 +1660,71 @@ function api_statuses_public_timeline($type)
/// @TODO move to top of file or somewhere better
api_register_func('api/statuses/public_timeline', 'api_statuses_public_timeline', true);
/**
* @brief Returns the list of public federated posts this node knows about
*
* @param string $type Return format: json, xml, atom, rss
* @return array|string
* @throws ForbiddenException
*/
function api_statuses_networkpublic_timeline($type)
{
$a = get_app();
if (api_user() === false) {
throw new ForbiddenException();
}
$user_info = api_get_user($a);
$since_id = x($_REQUEST, 'since_id') ? $_REQUEST['since_id'] : 0;
$max_id = x($_REQUEST, 'max_id') ? $_REQUEST['max_id'] : 0;
// pagination
$count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 20;
$page = x($_REQUEST, 'page') ? $_REQUEST['page'] : 1;
if ($page < 1) {
$page = 1;
}
$start = ($page - 1) * $count;
$sql_extra = '';
if ($max_id > 0) {
$sql_extra = 'AND `thread`.`iid` <= ' . intval($max_id);
}
$r = dba::p("SELECT " . item_fieldlists() . "
FROM `thread`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
" . item_joins() . "
WHERE `thread`.`uid` = 0
AND `verb` = ?
AND `item`.`id` > ?
$sql_extra
ORDER BY `thread`.`iid` DESC
LIMIT " . intval($start) . ", " . intval($count),
ACTIVITY_POST,
$since_id
);
$r = dba::inArray($r);
$ret = api_format_items($r, $user_info, false, $type);
$data = array('status' => $ret);
switch ($type) {
case "atom":
case "rss":
$data = api_rss_extra($a, $data, $user_info);
break;
}
return api_format_data("statuses", $type, $data);
}
/// @TODO move to top of file or somewhere better
api_register_func('api/statuses/networkpublic_timeline', 'api_statuses_networkpublic_timeline', true);
/**
* @TODO nothing to say?
*/