mirror of
https://github.com/friendica/friendica
synced 2025-04-24 12:30:10 +00:00
API: Reworked request parameter handling
This commit is contained in:
parent
dbd349b92e
commit
e5c1b90668
16 changed files with 233 additions and 265 deletions
|
@ -46,30 +46,29 @@ class ListTimeline extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
// Return results older than id
|
||||
$max_id = (int)!isset($_REQUEST['max_id']) ? 0 : $_REQUEST['max_id'];
|
||||
// Return results newer than id
|
||||
$since_id = (int)!isset($_REQUEST['since_id']) ? 0 : $_REQUEST['since_id'];
|
||||
// Return results immediately newer than id
|
||||
$min_id = (int)!isset($_REQUEST['min_id']) ? 0 : $_REQUEST['min_id'];
|
||||
// Maximum number of results to return. Defaults to 20.
|
||||
$limit = (int)!isset($_REQUEST['limit']) ? 20 : $_REQUEST['limit'];
|
||||
$request = self::getRequest([
|
||||
'max_id' => 0, // Return results older than id
|
||||
'since_id' => 0, // Return results newer than id
|
||||
'min_id' => 0, // Return results immediately newer than id
|
||||
'limit' => 20, // Maximum number of results to return. Defaults to 20.
|
||||
'with_muted' => false, // Unknown parameter
|
||||
]);
|
||||
|
||||
$params = ['order' => ['uri-id' => true], 'limit' => $limit];
|
||||
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
||||
|
||||
$condition = ["`uid` = ? AND `gravity` IN (?, ?) AND `contact-id` IN (SELECT `contact-id` FROM `group_member` WHERE `gid` = ?)",
|
||||
$uid, GRAVITY_PARENT, GRAVITY_COMMENT, $parameters['id']];
|
||||
|
||||
if (!empty($max_id)) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $max_id]);
|
||||
if (!empty($request['max_id'])) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $request['max_id']]);
|
||||
}
|
||||
|
||||
if (!empty($since_id)) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $since_id]);
|
||||
if (!empty($request['since_id'])) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $request['since_id']]);
|
||||
}
|
||||
|
||||
if (!empty($min_id)) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $min_id]);
|
||||
if (!empty($request['min_id'])) {
|
||||
$condition = DBA::mergeConditions($condition, ["`uri-id` > ?", $request['min_id']]);
|
||||
|
||||
$params['order'] = ['uri-id'];
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ class ListTimeline extends BaseApi
|
|||
}
|
||||
DBA::close($items);
|
||||
|
||||
if (!empty($min_id)) {
|
||||
if (!empty($request['min_id'])) {
|
||||
array_reverse($statuses);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue