aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ApiBundle/Controller
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-01 17:15:28 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-01 17:15:28 +0200
commit6273fefd5d945de1d871815a652f5a716e12e820 (patch)
treed8dbe70b412ce1a8f0515f6623e9e27e3190741b /src/Wallabag/ApiBundle/Controller
parentc4bf7af96f52aaafd13049e74f27b368eec79bf8 (diff)
downloadwallabag-6273fefd5d945de1d871815a652f5a716e12e820.tar.gz
wallabag-6273fefd5d945de1d871815a652f5a716e12e820.tar.zst
wallabag-6273fefd5d945de1d871815a652f5a716e12e820.zip
Add an exists endpoint in API
It should allow third party to check if an url was already saved by a user
Diffstat (limited to 'src/Wallabag/ApiBundle/Controller')
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index dd17ef97..b83e4266 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -23,6 +23,38 @@ class WallabagRestController extends FOSRestController
23 } 23 }
24 24
25 /** 25 /**
26 * Check if an entry exist by url
27 *
28 * @ApiDoc(
29 * parameters={
30 * {"name"="url", "dataType"="string", "required"=true, "format"="An url", "description"="Url to check if it exists"}
31 * }
32 * )
33 *
34 * @return JsonResponse
35 */
36 public function getEntriesExistsAction(Request $request)
37 {
38 $this->validateAuthentication();
39
40 $url = $request->query->get('url', '');
41
42 if (empty($url)) {
43 throw $this->createAccessDeniedException('URL is empty?, logged user id: '.$user->getId());
44 }
45
46 $res = $this->getDoctrine()
47 ->getRepository('WallabagCoreBundle:Entry')
48 ->findByUrlAndUserId($url, $this->getUser()->getId());
49
50 $exists = false === $res ? false : true;
51
52 $json = $this->get('serializer')->serialize(['exists' => $exists], 'json');
53
54 return (new JsonResponse())->setJson($json);
55 }
56
57 /**
26 * Retrieve all entries. It could be filtered by many options. 58 * Retrieve all entries. It could be filtered by many options.
27 * 59 *
28 * @ApiDoc( 60 * @ApiDoc(