- /**
- * Remote user likes one of our posts.
- * Confirm the post is ours, and save a local favorite event.
- */
-
- function handleFavorite()
- {
- $notice = $this->getNotice($this->activity->objects[0]);
- $profile = $this->ensureProfile()->localProfile();
-
- $old = Fave::pkeyGet(array('user_id' => $profile->id,
- 'notice_id' => $notice->id));
-
- if (!empty($old)) {
- // TRANS: Client exception.
- throw new ClientException(_m('This is already a favorite.'));
- }
-
- if (!Fave::addNew($profile, $notice)) {
- // TRANS: Client exception.
- throw new ClientException(_m('Could not save new favorite.'));
- }
- }
-
- /**
- * Remote user doesn't like one of our posts after all!
- * Confirm the post is ours, and save a local favorite event.
- */
- function handleUnfavorite()
- {
- $notice = $this->getNotice($this->activity->objects[0]);
- $profile = $this->ensureProfile()->localProfile();
-
- $fave = Fave::pkeyGet(array('user_id' => $profile->id,
- 'notice_id' => $notice->id));
- if (empty($fave)) {
- // TRANS: Client exception.
- throw new ClientException(_m('Notice was not favorited!'));
- }
-
- $fave->delete();
- }
-