Fixed max value check, improved request value fetching
This commit is contained in:
parent
a3173ccb50
commit
720a43461d
|
@ -296,7 +296,7 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
$value = max(filter_var($minimal_value, FILTER_VALIDATE_INT), $value);
|
||||
}
|
||||
if (!is_null($maximum_value)) {
|
||||
$value = min(filter_var($minimal_value, FILTER_VALIDATE_INT), $value);
|
||||
$value = min(filter_var($maximum_value, FILTER_VALIDATE_INT), $value);
|
||||
}
|
||||
} elseif (is_float($default)) {
|
||||
$value = filter_var($input[$parameter] ?? $default, FILTER_VALIDATE_FLOAT);
|
||||
|
@ -304,7 +304,7 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
$value = max(filter_var($minimal_value, FILTER_VALIDATE_FLOAT), $value);
|
||||
}
|
||||
if (!is_null($maximum_value)) {
|
||||
$value = min(filter_var($minimal_value, FILTER_VALIDATE_FLOAT), $value);
|
||||
$value = min(filter_var($maximum_value, FILTER_VALIDATE_FLOAT), $value);
|
||||
}
|
||||
} elseif (is_array($default)) {
|
||||
$value = filter_var($input[$parameter] ?? $default, FILTER_DEFAULT, ['flags' => FILTER_FORCE_ARRAY]);
|
||||
|
|
|
@ -49,6 +49,8 @@ class Seen extends BaseApi
|
|||
|
||||
$id = intval($request['id'] ?? 0);
|
||||
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
try {
|
||||
$Notify = DI::notify()->selectOneById($id);
|
||||
if ($Notify->uid !== $uid) {
|
||||
|
@ -65,8 +67,6 @@ class Seen extends BaseApi
|
|||
if ($Notify->otype === Notification\ObjectType::ITEM) {
|
||||
$item = Post::selectFirstForUser($uid, [], ['id' => $Notify->iid, 'uid' => $uid]);
|
||||
if (DBA::isResult($item)) {
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
// we found the item, return it to the user
|
||||
$ret = [DI::twitterStatus()->createFromUriId($item['uri-id'], $item['uid'], $include_entities)->toArray()];
|
||||
$data = ['status' => $ret];
|
||||
|
|
|
@ -45,6 +45,7 @@ class Conversation extends BaseApi
|
|||
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
|
||||
$count = $this->getRequestValue($request, 'count', 20, 1, 100);
|
||||
$page = $this->getRequestValue($request, 'page', 1, 1);
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
|
@ -82,8 +83,6 @@ class Conversation extends BaseApi
|
|||
throw new BadRequestException("There is no status with id $id.");
|
||||
}
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
$ret[] = DI::twitterStatus()->createFromUriId($status['uri-id'], $status['uid'], $include_entities)->toArray();
|
||||
|
|
|
@ -71,6 +71,7 @@ class Statuses extends BaseApi
|
|||
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
|
||||
$exclude_replies = $this->getRequestValue($request, 'exclude_replies', false);
|
||||
$conversation_id = $this->getRequestValue($request, 'conversation_id', 0, 0);
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
|
@ -95,8 +96,6 @@ class Statuses extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$items = [];
|
||||
while ($status = $this->dba->fetch($statuses)) {
|
||||
$items[] = $this->twitterStatus->createFromUriId($status['uri-id'], $status['uid'], $include_entities)->toArray();
|
||||
|
|
|
@ -62,6 +62,8 @@ class Tweets extends BaseApi
|
|||
$max_id = $_REQUEST['max_id'] ?? 0;
|
||||
$page = $_REQUEST['page'] ?? 1;
|
||||
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
|
@ -115,8 +117,6 @@ class Tweets extends BaseApi
|
|||
|
||||
$statuses = $statuses ?: Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
$ret[] = DI::twitterStatus()->createFromUriId($status['uri-id'], $status['uid'], $include_entities)->toArray();
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
namespace Friendica\Module\Api\Twitter\Statuses;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -50,7 +49,7 @@ class Destroy extends BaseApi
|
|||
|
||||
$this->logger->notice('API: api_statuses_destroy: ' . $id);
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
$ret = DI::twitterStatus()->createFromItemId($id, $uid, $include_entities)->toArray();
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ class HomeTimeline extends BaseApi
|
|||
$since_id = $this->getRequestValue($request, 'since_id', 0, 0);
|
||||
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
|
||||
$exclude_replies = $this->getRequestValue($request, 'exclude_replies', false);
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
$conversation_id = $this->getRequestValue($request, 'conversation_id', 0, 0);
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
@ -71,8 +72,6 @@ class HomeTimeline extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
$idarray = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
|
@ -46,6 +46,7 @@ class Mentions extends BaseApi
|
|||
$page = $this->getRequestValue($request, 'page', 1, 1);
|
||||
$since_id = $this->getRequestValue($request, 'since_id', 0, 0);
|
||||
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
|
@ -72,8 +73,6 @@ class Mentions extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
$ret[] = DI::twitterStatus()->createFromUriId($status['uri-id'], $status['uid'], $include_entities)->toArray();
|
||||
|
|
|
@ -38,12 +38,11 @@ class NetworkPublicTimeline extends BaseApi
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
|
||||
$since_id = $_REQUEST['since_id'] ?? 0;
|
||||
$max_id = $_REQUEST['max_id'] ?? 0;
|
||||
|
||||
// pagination
|
||||
$count = $_REQUEST['count'] ?? 20;
|
||||
$page = $_REQUEST['page'] ?? 1;
|
||||
$count = $this->getRequestValue($request, 'count', 20, 1, 100);
|
||||
$page = $this->getRequestValue($request, 'page', 1, 1);
|
||||
$since_id = $this->getRequestValue($request, 'since_id', 0, 0);
|
||||
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
|
@ -58,8 +57,6 @@ class NetworkPublicTimeline extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
$ret[] = DI::twitterStatus()->createFromUriId($status['uri-id'], $status['uid'], $include_entities)->toArray();
|
||||
|
|
|
@ -47,6 +47,7 @@ class PublicTimeline extends BaseApi
|
|||
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
|
||||
$exclude_replies = $this->getRequestValue($request, 'exclude_replies', false);
|
||||
$conversation_id = $this->getRequestValue($request, 'conversation_id', 0, 0);
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
|
@ -78,8 +79,6 @@ class PublicTimeline extends BaseApi
|
|||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
}
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
$ret[] = DI::twitterStatus()->createFromUriId($status['uri-id'], $status['uid'], $include_entities)->toArray();
|
||||
|
|
|
@ -79,7 +79,7 @@ class Show extends BaseApi
|
|||
throw new BadRequestException(sprintf("There is no status or conversation with the id %d.", $id));
|
||||
}
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
|
@ -43,14 +43,13 @@ class UserTimeline extends BaseApi
|
|||
Logger::info('api_statuses_user_timeline', ['api_user' => $uid, '_REQUEST' => $request]);
|
||||
|
||||
$cid = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, $uid);
|
||||
$since_id = $request['since_id'] ?? 0;
|
||||
$max_id = $request['max_id'] ?? 0;
|
||||
$exclude_replies = !empty($request['exclude_replies']);
|
||||
$conversation_id = $request['conversation_id'] ?? 0;
|
||||
|
||||
// pagination
|
||||
$count = $request['count'] ?? 20;
|
||||
$page = $request['page'] ?? 1;
|
||||
$count = $this->getRequestValue($request, 'count', 20, 1, 100);
|
||||
$page = $this->getRequestValue($request, 'page', 1, 1);
|
||||
$since_id = $this->getRequestValue($request, 'since_id', 0, 0);
|
||||
$max_id = $this->getRequestValue($request, 'max_id', 0, 0);
|
||||
$exclude_replies = $this->getRequestValue($request, 'exclude_replies', false);
|
||||
$conversation_id = $this->getRequestValue($request, 'conversation_id', 0, 0);
|
||||
$include_entities = $this->getRequestValue($request, 'include_entities', false);
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
|
@ -74,8 +73,6 @@ class UserTimeline extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
$ret = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
$ret[] = DI::twitterStatus()->createFromUriId($status['uri-id'], $status['uid'], $include_entities)->toArray();
|
||||
|
|
Loading…
Reference in New Issue
Block a user