Skip to content

Commit

Permalink
More fixes for 'fav' IM command: don't die with a fatal error if the …
Browse files Browse the repository at this point in the history
…notice has already been favored, and don't spew a warning when checking for user ID match.
  • Loading branch information
bvibber committed Mar 2, 2011
1 parent 4c09c1d commit 3eb900e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/command.php
Expand Up @@ -287,6 +287,18 @@ function __construct($user, $other)
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) {
Expand All @@ -300,7 +312,7 @@ function handle($channel)

$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);
}
Expand Down

0 comments on commit 3eb900e

Please sign in to comment.