Moved some FAVORITE handling from Activity plugin to Favorite

This commit is contained in:
Mikael Nordfeldth 2014-07-28 10:58:24 +02:00
parent 89704bcdee
commit 78dc376f01
2 changed files with 9 additions and 22 deletions

View File

@ -279,10 +279,6 @@ class ActivityPlugin extends Plugin
$adapter = null; $adapter = null;
switch ($notice->verb) { switch ($notice->verb) {
case ActivityVerb::FAVORITE:
case ActivityVerb::UNFAVORITE:
$adapter = new SystemListItem($nli);
break;
case ActivityVerb::JOIN: case ActivityVerb::JOIN:
$adapter = new JoinListItem($nli); $adapter = new JoinListItem($nli);
break; break;
@ -311,22 +307,6 @@ class ActivityPlugin extends Plugin
public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null) public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null)
{ {
switch ($stored->verb) { switch ($stored->verb) {
case ActivityVerb::FAVORITE:
$fave = Fave::getKV('uri', $stored->uri);
if (!empty($fave)) {
$stored = Notice::getKV('id', $fave->notice_id);
if (!empty($stored)) {
$target = $stored->asActivity($scoped);
if ($target->verb == ActivityVerb::POST) {
// "I like the thing you posted"
$act->objects = $target->objects;
} else {
// "I like that you did whatever you did"
$act->objects = array($target);
}
}
}
break;
case ActivityVerb::UNFAVORITE: case ActivityVerb::UNFAVORITE:
// FIXME: do something here // FIXME: do something here
break; break;

View File

@ -329,8 +329,15 @@ class Fave extends Managed_DataObject
{ {
$target = self::getTargetFromStored($stored); $target = self::getTargetFromStored($stored);
$act->target = $target->asActivityObject(); // The following logic was copied from StatusNet's Activity plugin
$act->objects = array(clone($act->target)); if (ActivityUtils::compareTypes($target->verb, array(ActivityVerb::POST))) {
// "I like the thing you posted"
$act->objects = $target->asActivity()->objects;
} else {
// "I like that you did whatever you did"
$act->target = $target->asActivityObject();
$act->objects = array(clone($act->target));
}
$act->context->replyToID = $target->getUri(); $act->context->replyToID = $target->getUri();
$act->context->replyToUrl = $target->getUrl(); $act->context->replyToUrl = $target->getUrl();
$act->title = ActivityUtils::verbToTitle($act->verb); $act->title = ActivityUtils::verbToTitle($act->verb);