]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Favorite/actions/apifavoritecreate.php
Move AlreadyFulfilled check to Fave::addNew
[quix0rs-gnu-social.git] / plugins / Favorite / actions / apifavoritecreate.php
index 736bd7b0a19eaa720cf49040bd9255912f9c4afa..7e63b199e2285a9fd77327816a40a2a7dbe0c51d 100644 (file)
@@ -89,20 +89,13 @@ class ApiFavoriteCreateAction extends ApiAuthAction
             );
         }
 
-        // Note: Twitter lets you fave things repeatedly via API.
-
-        if (Fave::existsForProfile($this->notice, $this->scoped)) {
-            $this->clientError(
-                // TRANS: Client error displayed when trying to mark a notice favourite that already is a favourite.
-                _('This status is already a favorite.'),
-                403,
-                $this->format
-            );
+        try {
+            $stored = Fave::addNew($this->scoped, $this->notice);
+        } catch (AlreadyFulfilledException $e) {
+            // Note: Twitter lets you fave things repeatedly via API.
+            $this->clientError($e->getMessage(), 403);
         }
 
-        // throws exception on failure
-        $stored = Fave::addNew($this->scoped, $this->notice);
-
         if ($this->format == 'xml') {
             $this->showSingleXmlStatus($this->notice);
         } elseif ($this->format == 'json') {