From: Mikael Nordfeldth Date: Mon, 28 Jul 2014 08:58:24 +0000 (+0200) Subject: Moved some FAVORITE handling from Activity plugin to Favorite X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=78dc376f017cd7a9ee746e961dd8eefb8941eff2;p=quix0rs-gnu-social.git Moved some FAVORITE handling from Activity plugin to Favorite --- diff --git a/plugins/Activity/ActivityPlugin.php b/plugins/Activity/ActivityPlugin.php index 3f2cee11d2..91d2867c23 100644 --- a/plugins/Activity/ActivityPlugin.php +++ b/plugins/Activity/ActivityPlugin.php @@ -279,10 +279,6 @@ class ActivityPlugin extends Plugin $adapter = null; switch ($notice->verb) { - case ActivityVerb::FAVORITE: - case ActivityVerb::UNFAVORITE: - $adapter = new SystemListItem($nli); - break; case ActivityVerb::JOIN: $adapter = new JoinListItem($nli); break; @@ -311,22 +307,6 @@ class ActivityPlugin extends Plugin public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null) { 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: // FIXME: do something here break; diff --git a/plugins/Favorite/classes/Fave.php b/plugins/Favorite/classes/Fave.php index 96e9520b3d..7a18bbfd44 100644 --- a/plugins/Favorite/classes/Fave.php +++ b/plugins/Favorite/classes/Fave.php @@ -329,8 +329,15 @@ class Fave extends Managed_DataObject { $target = self::getTargetFromStored($stored); - $act->target = $target->asActivityObject(); - $act->objects = array(clone($act->target)); + // The following logic was copied from StatusNet's Activity plugin + 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->replyToUrl = $target->getUrl(); $act->title = ActivityUtils::verbToTitle($act->verb);