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().
This commit is contained in:
Evan Prodromou 2010-12-06 15:21:34 -05:00
parent 2c5de55b4b
commit 65bbd991c2

View File

@ -219,64 +219,50 @@ class ActivityPlugin extends Plugin
return true; 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)) { if (!empty($na)) {
$verb = $act->verb;
}
return true; $activity->verb = $na->verb;
}
function onStartActivityDefaultObjectType(&$notice, &$xs, &$type) // wipe the old object!
{
$act = Notice_activity::staticGet('notice_id', $notice->id);
if (!empty($act)) { $activity->objects = array();
// no default object
return false;
}
return true; switch ($na->verb)
}
function onStartActivityObjects(&$notice, &$xs, &$objects)
{
$act = Notice_activity::staticGet('notice_id', $notice->id);
if (!empty($act)) {
switch ($act->verb)
{ {
case ActivityVerb::FOLLOW: case ActivityVerb::FOLLOW:
case ActivityVerb::UNFOLLOW: case ActivityVerb::UNFOLLOW:
$profile = Profile::fromURI($act->object); $profile = Profile::fromURI($na->object);
if (!empty($profile)) { if (!empty($profile)) {
$objects[] = ActivityObject::fromProfile($profile); $activity->objects[] = ActivityObject::fromProfile($profile);
} }
break; break;
case ActivityVerb::FAVORITE: case ActivityVerb::FAVORITE:
case ActivityVerb::UNFAVORITE: case ActivityVerb::UNFAVORITE:
$notice = Notice::staticGet('uri', $act->object); $target = Notice::staticGet('uri', $na->object);
if (!empty($notice)) { if (!empty($target)) {
$objects[] = $notice->asActivity(); $activity->objects[] = ActivityObject::fromNotice($target);
} }
break; break;
case ActivityVerb::JOIN: case ActivityVerb::JOIN:
case ActivityVerb::LEAVE: case ActivityVerb::LEAVE:
$group = User_group::staticGet('uri', $act->object); $group = User_group::staticGet('uri', $na->object);
if (!empty($notice)) { if (!empty($notice)) {
$objects[] = ActivityObject::fromGroup($group); $activity->objects[] = ActivityObject::fromGroup($group);
} }
break; break;
default: default:
break; break;
} }
} }
return true; return true;
} }
function onPluginVersion(&$versions) function onPluginVersion(&$versions)
{ {
$versions[] = array('name' => 'Activity', $versions[] = array('name' => 'Activity',