Harmonized API parameters for all timeline endpoints
This commit is contained in:
parent
e3d227f3c9
commit
50ca38a0f7
|
@ -50,8 +50,8 @@ class Home extends BaseApi
|
||||||
'local' => false, // Return only local statuses?
|
'local' => false, // Return only local statuses?
|
||||||
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
|
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
|
||||||
'only_media' => false, // Show only statuses with media attached? Defaults to false.
|
'only_media' => false, // Show only statuses with media attached? Defaults to false.
|
||||||
'local' => false, // Show only local statuses? Defaults to false.
|
|
||||||
'remote' => false, // Show only remote statuses? Defaults to false.
|
'remote' => false, // Show only remote statuses? Defaults to false.
|
||||||
|
'exclude_replies' => false, // Don't show comments
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
||||||
|
@ -81,14 +81,14 @@ class Home extends BaseApi
|
||||||
Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
|
Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request['local']) {
|
|
||||||
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request['remote']) {
|
if ($request['remote']) {
|
||||||
$condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
|
$condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request['exclude_replies']) {
|
||||||
|
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||||
|
}
|
||||||
|
|
||||||
$items = Post::selectForUser($uid, ['uri-id'], $condition, $params);
|
$items = Post::selectForUser($uid, ['uri-id'], $condition, $params);
|
||||||
|
|
||||||
$statuses = [];
|
$statuses = [];
|
||||||
|
|
|
@ -55,6 +55,7 @@ class ListTimeline extends BaseApi
|
||||||
'only_media' => false, // Show only statuses with media attached? Defaults to false.
|
'only_media' => false, // Show only statuses with media attached? Defaults to false.
|
||||||
'local' => false, // Show only local statuses? Defaults to false.
|
'local' => false, // Show only local statuses? Defaults to false.
|
||||||
'remote' => false, // Show only remote statuses? Defaults to false.
|
'remote' => false, // Show only remote statuses? Defaults to false.
|
||||||
|
'exclude_replies' => false, // Don't show comments
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
||||||
|
@ -81,6 +82,10 @@ class ListTimeline extends BaseApi
|
||||||
Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
|
Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request['exclude_replies']) {
|
||||||
|
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request['local']) {
|
if ($request['local']) {
|
||||||
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
|
$condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `origin`)"]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ class PublicTimeline extends BaseApi
|
||||||
'min_id' => 0, // Return results immediately newer than this id
|
'min_id' => 0, // Return results immediately newer than this id
|
||||||
'limit' => 20, // Maximum number of results to return. Defaults to 20.
|
'limit' => 20, // Maximum number of results to return. Defaults to 20.
|
||||||
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
|
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
|
||||||
|
'exclude_replies' => false, // Don't show comments
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
||||||
|
@ -83,6 +84,10 @@ class PublicTimeline extends BaseApi
|
||||||
$params['order'] = ['uri-id'];
|
$params['order'] = ['uri-id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request['exclude_replies']) {
|
||||||
|
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||||
|
}
|
||||||
|
|
||||||
$items = Post::selectForUser(0, ['uri-id', 'uid'], $condition, $params);
|
$items = Post::selectForUser(0, ['uri-id', 'uid'], $condition, $params);
|
||||||
|
|
||||||
$statuses = [];
|
$statuses = [];
|
||||||
|
|
|
@ -56,6 +56,7 @@ class Tag extends BaseApi
|
||||||
'min_id' => 0, // Return results immediately newer than this ID.
|
'min_id' => 0, // Return results immediately newer than this ID.
|
||||||
'limit' => 20, // Maximum number of results to return. Defaults to 20.
|
'limit' => 20, // Maximum number of results to return. Defaults to 20.
|
||||||
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
|
'with_muted' => false, // Pleroma extension: return activities by muted (not by blocked!) users.
|
||||||
|
'exclude_replies' => false, // Don't show comments
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
$params = ['order' => ['uri-id' => true], 'limit' => $request['limit']];
|
||||||
|
@ -77,6 +78,10 @@ class Tag extends BaseApi
|
||||||
Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
|
Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request['exclude_replies']) {
|
||||||
|
$condition = DBA::mergeConditions($condition, ['gravity' => GRAVITY_PARENT]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($request['max_id'])) {
|
if (!empty($request['max_id'])) {
|
||||||
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $request['max_id']]);
|
$condition = DBA::mergeConditions($condition, ["`uri-id` < ?", $request['max_id']]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue