From efd351c98fa0caa4c8df9c7ff6965c537524f12a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 1 May 2017 09:21:59 +0200 Subject: Added limit --- src/Wallabag/ApiBundle/Controller/EntryRestController.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Wallabag/ApiBundle/Controller') diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index ae6f0e3f..7c3e778e 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php @@ -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) { -- cgit v1.2.3