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