Move AlreadyFulfilled check to Fave::addNew

This commit is contained in:
Mikael Nordfeldth
2015-03-10 11:50:16 +01:00
parent fa080328cf
commit 8a273eef20
5 changed files with 11 additions and 34 deletions

View 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;