X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FFavorite%2Flib%2Ffavcommand.php;h=6c7d0d1946ae1c09c4418ebcabc228937ad1f268;hb=8a273eef2078d77faad027ce46a4cfca0ada8225;hp=41fd0b0b883e2533b5652399ab9c5d584e62bb37;hpb=7e597ea7cc85c3b7c7226d443b21fb3252c8fd7e;p=quix0rs-gnu-social.git diff --git a/plugins/Favorite/lib/favcommand.php b/plugins/Favorite/lib/favcommand.php index 41fd0b0b88..6c7d0d1946 100644 --- a/plugins/Favorite/lib/favcommand.php +++ b/plugins/Favorite/lib/favcommand.php @@ -14,37 +14,12 @@ class FavCommand extends Command { $notice = $this->getNotice($this->other); - $fave = new Fave(); - $fave->user_id = $this->user->id; - $fave->notice_id = $notice->id; - $fave->find(); - - if ($fave->fetch()) { - // TRANS: Error message text shown when a favorite could not be set because it has already been favorited. - $channel->error($this->user, _('Could not create favorite: Already favorited.')); - return; - } - - $fave = Fave::addNew($this->user->getProfile(), $notice); - - if (!$fave) { - // TRANS: Error message text shown when a favorite could not be set. - $channel->error($this->user, _('Could not create favorite.')); - return; - } - - // @fixme favorite notification should be triggered - // at a lower level - - $other = User::getKV('id', $notice->profile_id); - - if ($other && $other->id != $this->user->id) { - if ($other->email && $other->emailnotifyfav) { - mail_notify_fave($other, $this->user, $notice); - } - } - - Fave::blowCacheForProfileId($this->user->id); + try { + $fave = Fave::addNew($this->user->getProfile(), $notice); + } catch (Exception $e) { + $channel->error($this->user, $e->getMessage()); + return; + } // TRANS: Text shown when a notice has been marked as favourite successfully. $channel->output($this->user, _('Notice marked as fave.'));