]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
More fixes for 'fav' IM command: don't die with a fatal error if the notice has alrea...
authorBrion Vibber <brion@pobox.com>
Wed, 2 Mar 2011 01:09:41 +0000 (17:09 -0800)
committerBrion Vibber <brion@pobox.com>
Wed, 2 Mar 2011 01:17:41 +0000 (17:17 -0800)
lib/command.php

index 852d0a8f7cea78123a54c839c433617577d95bc8..39fb283dd87d82bbc02b02dcc30647fa1fde853b 100644 (file)
@@ -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);
             }