From 3107f92acb638bb5bf8067daaa5500ae65b5b116 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 16 Mar 2016 21:07:01 +0100 Subject: Don't add entry through API if it already exists --- src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/Wallabag/ApiBundle/Controller') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 29cab1f4..2633a311 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -112,10 +112,14 @@ class WallabagRestController extends FOSRestController $isArchived = $request->request->get('archive'); $isStarred = $request->request->get('starred'); - $entry = $this->get('wallabag_core.content_proxy')->updateEntry( - new Entry($this->getUser()), - $url - ); + $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId()); + + if (false === $entry) { + $entry = $this->get('wallabag_core.content_proxy')->updateEntry( + new Entry($this->getUser()), + $url + ); + } $tags = $request->request->get('tags', ''); if (!empty($tags)) { -- cgit v1.2.3