]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Favorite/actions/apifavoritecreate.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / Favorite / actions / apifavoritecreate.php
index 8a273740534c639b6f681a78cbd2677681b23c2f..7ff8f391b2466309df4d109866c1e16df438cf49 100644 (file)
@@ -101,20 +101,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') {