list_mode: 0
fetching_error_message: |
wallabag can't retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/master/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.
+ api_limit_mass_actions: 10
wallabag_user:
registration_enabled: "%fosuser_registration%"
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;
* )
*
* @return JsonResponse
+ *
+ * @throws Symfony\Component\Config\Definition\Exception\Exception When limit is reached
*/
public function postEntriesListAction(Request $request)
{
$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) {
->scalarNode('list_mode')
->defaultValue(1)
->end()
+ ->scalarNode('api_limit_mass_actions')
+ ->defaultValue(10)
+ ->end()
->end()
;
$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');
$this->assertFalse($content[1]['entry']);
$this->assertEquals('http://0.0.0.0/entry3', $content[1]['url']);
}
+
+ /**
+ * @expectedException Symfony\Component\Config\Definition\Exception\Exception
+ * @expectedExceptionMessage API limit reached
+ */
+ public function testLimitBulkAction()
+ {
+ $list = [
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ 'http://0.0.0.0/entry1',
+ ];
+
+ $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list));
+ }
}