function execute($channel) { $recipient = common_relative_profile($this->user, common_canonical_nickname($this->other)); if (!$recipient) { $channel->error($this->user, _('No such user.')); return; } $notice = $recipient->getCurrentNotice(); if (!$notice) { $channel->error($this->user, _('User has no last notice')); return; } $fave = Fave::addNew($this->user, $notice); if (!$fave) { $channel->error($this->user, _('Could not create favorite.')); return; } $other = User::staticGet('id', $recipient->id); if ($other && $other->id != $user->id) { if ($other->email && $other->emailnotifyfav) { mail_notify_fave($other, $this->user, $notice); } } $this->user->blowFavesCache(); $channel->output($this->user, _('Notice marked as fave.')); }
public function onEndFavorNotice(Profile $actor, Notice $target) { try { $notice_author = $target->getProfile(); // Don't notify ourselves of our own favorite on our own notice, // or if it's a remote user (since we don't know their email addresses etc.) if ($notice_author->id == $actor->id || !$notice_author->isLocal()) { return true; } $local_user = $notice_author->getUser(); mail_notify_fave($local_user, $actor, $target); } catch (Exception $e) { // Mm'kay, probably not a local user. Let's skip this favor notification. } }
function handle($channel) { $notice = $this->getNotice($this->other); $fave = Fave::addNew($this->user->getProfile(), $notice); if (!$fave) { // TRANS: Error message text shown when a favorite could not be set. $channel->error($this->user, _('Could not create favorite.')); return; } // @fixme favorite notification should be triggered // at a lower level $other = User::staticGet('id', $notice->profile_id); if ($other && $other->id != $user->id) { if ($other->email && $other->emailnotifyfav) { mail_notify_fave($other, $this->user, $notice); } } $this->user->blowFavesCache(); // TRANS: Text shown when a notice has been marked as favourite successfully. $channel->output($this->user, _('Notice marked as fave.')); }
function handle($channel) { $notice = $this->getNotice($this->other); $fave = Fave::addNew($this->user->getProfile(), $notice); if (!$fave) { $channel->error($this->user, _('Could not create favorite.')); return; } // @fixme favorite notification should be triggered // at a lower level $other = User::staticGet('id', $notice->profile_id); if ($other && $other->id != $user->id) { if ($other->email && $other->emailnotifyfav) { mail_notify_fave($other, $this->user, $notice); } } $this->user->blowFavesCache(); $channel->output($this->user, _('Notice marked as fave.')); }
/** * Notifies a user when his notice is favorited. * * @param class $notice favorited notice * @param class $user user declaring a favorite * * @return void */ function notify($notice, $user) { $other = User::staticGet('id', $notice->profile_id); if ($other && $other->id != $user->id) { if ($other->email && $other->emailnotifyfav) { mail_notify_fave($other, $user, $notice); } // XXX: notify by IM // XXX: notify by SMS } }