Commit e42db528 authored by Brion Vibber's avatar Brion Vibber

More fixes for 'fav' IM command: don't die with a fatal error if the notice...

More fixes for 'fav' IM command: don't die with a fatal error if the notice has already been favored, and don't spew a warning when checking for user ID match.
parent d09aa9c9
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment