X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fcommand.php;h=29aa286d1db0d890950a962f0eb3053db4dceb7b;hb=119d0f7dbab40f30170ba263de78d7e9cea984db;hp=3fb4d76c75f131ff74f245362a646cde59d43086;hpb=6e894c010fc0e7ddaaafa8795634d6343019aafb;p=quix0rs-gnu-social.git diff --git a/lib/command.php b/lib/command.php index 3fb4d76c75..29aa286d1d 100644 --- a/lib/command.php +++ b/lib/command.php @@ -287,6 +287,18 @@ class FavCommand extends Command function handle($channel) { $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) { @@ -300,7 +312,7 @@ class FavCommand extends Command $other = User::staticGet('id', $notice->profile_id); - if ($other && $other->id != $user->id) { + if ($other && $other->id != $this->user->id) { if ($other->email && $other->emailnotifyfav) { mail_notify_fave($other, $this->user, $notice); }