]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Moved some FAVORITE handling from Activity plugin to Favorite
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Jul 2014 08:58:24 +0000 (10:58 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 28 Jul 2014 08:58:24 +0000 (10:58 +0200)
plugins/Activity/ActivityPlugin.php
plugins/Favorite/classes/Fave.php

index 3f2cee11d2ad197aa18bdb18797d3284d97f7267..91d2867c23c27d7b5c8b3f6c23de667315f45c99 100644 (file)
@@ -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;
index 96e9520b3d45c355e75c063ce7df117ab7134c74..7a18bbfd4471308b35d0c5ba2f4be6aae4981922 100644 (file)
@@ -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);