mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-12 16:58:37 +00:00
Added limit
This commit is contained in:
parent
7fa844a349
commit
efd351c98f
5 changed files with 37 additions and 0 deletions
|
@ -5,6 +5,7 @@ namespace Wallabag\ApiBundle\Controller;
|
|||
use Hateoas\Configuration\Route;
|
||||
use Hateoas\Representation\Factory\PagerfantaFactory;
|
||||
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
@ -229,6 +230,8 @@ class EntryRestController extends WallabagRestController
|
|||
* )
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
* @throws Symfony\Component\Config\Definition\Exception\Exception When limit is reached
|
||||
*/
|
||||
public function postEntriesListAction(Request $request)
|
||||
{
|
||||
|
@ -237,6 +240,12 @@ class EntryRestController extends WallabagRestController
|
|||
$urls = json_decode($request->query->get('urls', []));
|
||||
$results = [];
|
||||
|
||||
$limit = $this->container->getParameter('wallabag_core.api_limit_mass_actions');
|
||||
|
||||
if (count($urls) > $limit) {
|
||||
throw new Exception('API limit reached');
|
||||
}
|
||||
|
||||
// handle multiple urls
|
||||
if (!empty($urls)) {
|
||||
foreach ($urls as $key => $url) {
|
||||
|
|
|
@ -47,6 +47,9 @@ class Configuration implements ConfigurationInterface
|
|||
->scalarNode('list_mode')
|
||||
->defaultValue(1)
|
||||
->end()
|
||||
->scalarNode('api_limit_mass_actions')
|
||||
->defaultValue(10)
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ class WallabagCoreExtension extends Extension
|
|||
$container->setParameter('wallabag_core.action_mark_as_read', $config['action_mark_as_read']);
|
||||
$container->setParameter('wallabag_core.list_mode', $config['list_mode']);
|
||||
$container->setParameter('wallabag_core.fetching_error_message', $config['fetching_error_message']);
|
||||
$container->setParameter('wallabag_core.api_limit_mass_actions', $config['api_limit_mass_actions']);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yml');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue