Favorites are now being stored from activities
This commit is contained in:
@@ -130,47 +130,6 @@ class UsersalmonAction extends SalmonAction
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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]);
|
||||
|
||||
$old = Fave::pkeyGet(array('user_id' => $this->actor->id,
|
||||
'notice_id' => $notice->id));
|
||||
|
||||
if ($old instanceof Fave) {
|
||||
// TRANS: Client exception.
|
||||
throw new AlreadyFulfilledException(_m('This is already a favorite.'));
|
||||
}
|
||||
|
||||
if (!Fave::addNew($this->actor, $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]);
|
||||
|
||||
$fave = Fave::pkeyGet(array('user_id' => $this->actor->id,
|
||||
'notice_id' => $notice->id));
|
||||
if (!$fave instanceof Fave) {
|
||||
// TRANS: Client exception.
|
||||
throw new AlreadyFulfilledException(_m('Notice was not favorited!'));
|
||||
}
|
||||
|
||||
$fave->delete();
|
||||
}
|
||||
|
||||
function handleTag()
|
||||
{
|
||||
if ($this->activity->target->type == ActivityObject::_LIST) {
|
||||
|
@@ -91,12 +91,6 @@ class SalmonAction extends Action
|
||||
case ActivityVerb::SHARE:
|
||||
$this->handleShare();
|
||||
break;
|
||||
case ActivityVerb::FAVORITE:
|
||||
$this->handleFavorite();
|
||||
break;
|
||||
case ActivityVerb::UNFAVORITE:
|
||||
$this->handleUnfavorite();
|
||||
break;
|
||||
case ActivityVerb::FOLLOW:
|
||||
case ActivityVerb::FRIEND:
|
||||
$this->handleFollow();
|
||||
@@ -152,18 +146,6 @@ class SalmonAction extends Action
|
||||
throw new ClientException(_m('This target does not understand unfollows.'));
|
||||
}
|
||||
|
||||
function handleFavorite()
|
||||
{
|
||||
// TRANS: Client exception.
|
||||
throw new ClientException(_m('This target does not understand favorites.'));
|
||||
}
|
||||
|
||||
function handleUnfavorite()
|
||||
{
|
||||
// TRANS: Client exception.
|
||||
throw new ClientException(_m('This target does not understand unfavorites.'));
|
||||
}
|
||||
|
||||
function handleShare()
|
||||
{
|
||||
// TRANS: Client exception.
|
||||
|
Reference in New Issue
Block a user