]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Favorite/classes/Fave.php
Move AlreadyFulfilled check to Fave::addNew
[quix0rs-gnu-social.git] / plugins / Favorite / classes / Fave.php
index 094b65feaa94fd19b38f6b5dd12e6af5b48ebd10..ba0d04ba25f9a9ecaaea8ca35ffab4e6ec466039 100644 (file)
@@ -48,6 +48,11 @@ class Fave extends Managed_DataObject
      * @throws Exception on failure
      */
     static function addNew(Profile $actor, Notice $target) {
+        if (self::existsForProfile($target, $actor)) {
+            // TRANS: Client error displayed when trying to mark a notice as favorite that already is a favorite.
+            throw new AlreadyFulfilledException(_('You have already favorited this!'));
+        }
+
         $act = new Activity();
         $act->type    = ActivityObject::ACTIVITY;
         $act->verb    = ActivityVerb::FAVORITE;