]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ApiBundle/Controller/WallabagRestController.php
fix api properties and typo
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / WallabagRestController.php
index 29cab1f4df0f6b4f465a949bda377cfb3f1e5811..3265ba3876037292eac04123b2b92e8e4b212046 100644 (file)
@@ -112,21 +112,25 @@ 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)) {
             $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
         }
 
-        if (true === (bool) $isStarred) {
+        if ($isStarred === 'true') {
             $entry->setStarred(true);
         }
 
-        if (true === (bool) $isArchived) {
+        if ($isArchived  === 'true') {
             $entry->setArchived(true);
         }