]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Use new hooks for Notice::asActivity()
authorEvan Prodromou <evan@status.net>
Mon, 6 Dec 2010 20:21:34 +0000 (15:21 -0500)
committerEvan Prodromou <evan@status.net>
Mon, 6 Dec 2010 20:21:34 +0000 (15:21 -0500)
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().

ActivityPlugin.php

index 769ff369307a33b668fc7a59ef63712ac44078f0..c6d79f0cd800a387537fc1c5eaa7565f755192b7 100644 (file)
@@ -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',