diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2017-05-01 09:21:59 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2017-05-01 09:26:12 +0200 |
commit | efd351c98fa0caa4c8df9c7ff6965c537524f12a (patch) | |
tree | 78a268e63d8983b88c95a2518df62b9b06889827 /src/Wallabag/ApiBundle | |
parent | 7fa844a34983f9929348e70ddd408cf6ba5811b6 (diff) | |
download | wallabag-efd351c98fa0caa4c8df9c7ff6965c537524f12a.tar.gz wallabag-efd351c98fa0caa4c8df9c7ff6965c537524f12a.tar.zst wallabag-efd351c98fa0caa4c8df9c7ff6965c537524f12a.zip |
Added limit
Diffstat (limited to 'src/Wallabag/ApiBundle')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/EntryRestController.php | 9 |
1 files changed, 9 insertions, 0 deletions
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; | |||
5 | use Hateoas\Configuration\Route; | 5 | use Hateoas\Configuration\Route; |
6 | use Hateoas\Representation\Factory\PagerfantaFactory; | 6 | use Hateoas\Representation\Factory\PagerfantaFactory; |
7 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; | 7 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; |
8 | use Symfony\Component\Config\Definition\Exception\Exception; | ||
8 | use Symfony\Component\HttpFoundation\Request; | 9 | use Symfony\Component\HttpFoundation\Request; |
9 | use Symfony\Component\HttpFoundation\JsonResponse; | 10 | use Symfony\Component\HttpFoundation\JsonResponse; |
10 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | 11 | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
@@ -229,6 +230,8 @@ class EntryRestController extends WallabagRestController | |||
229 | * ) | 230 | * ) |
230 | * | 231 | * |
231 | * @return JsonResponse | 232 | * @return JsonResponse |
233 | * | ||
234 | * @throws Symfony\Component\Config\Definition\Exception\Exception When limit is reached | ||
232 | */ | 235 | */ |
233 | public function postEntriesListAction(Request $request) | 236 | public function postEntriesListAction(Request $request) |
234 | { | 237 | { |
@@ -237,6 +240,12 @@ class EntryRestController extends WallabagRestController | |||
237 | $urls = json_decode($request->query->get('urls', [])); | 240 | $urls = json_decode($request->query->get('urls', [])); |
238 | $results = []; | 241 | $results = []; |
239 | 242 | ||
243 | $limit = $this->container->getParameter('wallabag_core.api_limit_mass_actions'); | ||
244 | |||
245 | if (count($urls) > $limit) { | ||
246 | throw new Exception('API limit reached'); | ||
247 | } | ||
248 | |||
240 | // handle multiple urls | 249 | // handle multiple urls |
241 | if (!empty($urls)) { | 250 | if (!empty($urls)) { |
242 | foreach ($urls as $key => $url) { | 251 | foreach ($urls as $key => $url) { |