From: Evan Prodromou Date: Mon, 6 Dec 2010 20:21:34 +0000 (-0500) Subject: Use new hooks for Notice::asActivity() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=65bbd991c286b045be1bf9a7015112a0c48c149d;p=quix0rs-gnu-social.git Use new hooks for Notice::asActivity() Changed the atom activity generation code so it uses the new hooks built into Notice::asActivity() rather than the hooks in the old Notice::asAtomEntry(). --- diff --git a/ActivityPlugin.php b/ActivityPlugin.php index 769ff36930..c6d79f0cd8 100644 --- a/ActivityPlugin.php +++ b/ActivityPlugin.php @@ -219,64 +219,50 @@ class ActivityPlugin extends Plugin return true; } - function onStartActivityVerb(&$notice, &$xs, &$verb) + function onEndNoticeAsActivity($notice, &$activity) { - $act = Notice_activity::staticGet('notice_id', $notice->id); + $na = Notice_activity::staticGet('notice_id', $notice->id); - if (!empty($act)) { - $verb = $act->verb; - } - - return true; - } + if (!empty($na)) { - function onStartActivityDefaultObjectType(&$notice, &$xs, &$type) - { - $act = Notice_activity::staticGet('notice_id', $notice->id); - - if (!empty($act)) { - // no default object - return false; - } + $activity->verb = $na->verb; - return true; - } + // wipe the old object! - function onStartActivityObjects(&$notice, &$xs, &$objects) - { - $act = Notice_activity::staticGet('notice_id', $notice->id); + $activity->objects = array(); - if (!empty($act)) { - switch ($act->verb) + switch ($na->verb) { case ActivityVerb::FOLLOW: case ActivityVerb::UNFOLLOW: - $profile = Profile::fromURI($act->object); + $profile = Profile::fromURI($na->object); if (!empty($profile)) { - $objects[] = ActivityObject::fromProfile($profile); + $activity->objects[] = ActivityObject::fromProfile($profile); } break; case ActivityVerb::FAVORITE: case ActivityVerb::UNFAVORITE: - $notice = Notice::staticGet('uri', $act->object); - if (!empty($notice)) { - $objects[] = $notice->asActivity(); + $target = Notice::staticGet('uri', $na->object); + if (!empty($target)) { + $activity->objects[] = ActivityObject::fromNotice($target); } break; case ActivityVerb::JOIN: case ActivityVerb::LEAVE: - $group = User_group::staticGet('uri', $act->object); + $group = User_group::staticGet('uri', $na->object); if (!empty($notice)) { - $objects[] = ActivityObject::fromGroup($group); + $activity->objects[] = ActivityObject::fromGroup($group); } break; default: break; } } + return true; } + function onPluginVersion(&$versions) { $versions[] = array('name' => 'Activity',