diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index a5ddc47255..bfc9c91606 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -243,7 +243,7 @@ class EventPlugin extends MicroAppPlugin * * @return ActivityObject */ - function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null) { + protected function extendActivity(Notice $stored, Activity $act, Profile $scoped=null) { switch ($stored->object_type) { case RSVP::POSITIVE: case RSVP::NEGATIVE: diff --git a/plugins/Favorite/FavoritePlugin.php b/plugins/Favorite/FavoritePlugin.php index 82409d23f7..9f2618d582 100644 --- a/plugins/Favorite/FavoritePlugin.php +++ b/plugins/Favorite/FavoritePlugin.php @@ -187,6 +187,24 @@ class FavoritePlugin extends ActivityHandlerPlugin return $object; } + // FIXME: Put this in lib/activityhandlerplugin.php when we're ready + // with the other microapps/activityhandlers as well. + // Also it should be StartNoticeAsActivity (with a prepped Activity, including ->context etc.) + public function onEndNoticeAsActivity(Notice $stored, Activity $act, Profile $scoped=null) + { + if (!$this->isMyNotice($stored)) { + return true; + } + + common_debug('Extending activity '.$stored->id.' with '.get_called_class()); + $this->extendActivity($stored, $act, $scoped); + return false; + } + + public function extendActivity(Notice $stored, Activity $act, Profile $scoped=null) + { + Fave::extendActivity($stored, $act, $scoped); + } public function activityObjectFromNotice(Notice $notice) { diff --git a/plugins/Favorite/classes/Fave.php b/plugins/Favorite/classes/Fave.php index 3703c844da..96e9520b3d 100644 --- a/plugins/Favorite/classes/Fave.php +++ b/plugins/Favorite/classes/Fave.php @@ -271,6 +271,19 @@ class Fave extends Managed_DataObject return $object; } + /** + * Retrieves the _targeted_ notice of a verb (such as the notice that was + * _favorited_, but not the favorite activity itself). + * + * @param Notice $stored The activity notice. + * + * @throws NoResultException when it can't find what it's looking for. + */ + static public function getTargetFromStored(Notice $stored) + { + return self::fromStored($stored)->getTarget(); + } + static public function getObjectType() { return 'activity'; @@ -312,6 +325,17 @@ class Fave extends Managed_DataObject return $object; } + static public function extendActivity(Notice $stored, Activity $act, Profile $scoped=null) + { + $target = self::getTargetFromStored($stored); + + $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); + } + static function saveActivityObject(ActivityObject $actobj, Notice $stored) { $object = self::parseActivityObject($actobj, $stored);