]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Call it compareVerbs when comparing verbs
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 10 Sep 2015 13:27:40 +0000 (15:27 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 10 Sep 2015 13:27:40 +0000 (15:27 +0200)
lib/activity.php
lib/activityhandlerplugin.php
lib/activityutils.php
plugins/Favorite/FavoritePlugin.php
plugins/Favorite/classes/Fave.php

index 2d3930df0d85ec46207e6ff63fa9790556f3f664..4db3b9ff4e801c2bab10772ebb800ddadf578a0c 100644 (file)
@@ -244,7 +244,7 @@ class Activity
 
         if (!empty($targetEl)) {
             $this->target = new ActivityObject($targetEl);
-        } elseif (ActivityUtils::compareTypes($this->verb, array(ActivityVerb::FAVORITE))) {
+        } elseif (ActivityUtils::compareVerbs($this->verb, array(ActivityVerb::FAVORITE))) {
             // StatusNet didn't send a 'target' for their Favorite atom entries
             $this->target = clone($this->objects[0]);
         }
index 529749cc1ddc46b32373a6f12b65744db19657c2..6639e2782280903094d56078fd1ad71148bff6ac 100644 (file)
@@ -104,7 +104,7 @@ abstract class ActivityHandlerPlugin extends Plugin
 
     function isMyVerb($verb) {
         $verb = $verb ?: ActivityVerb::POST;    // post is the default verb
-        return ActivityUtils::compareTypes($verb, $this->verbs());
+        return ActivityUtils::compareVerbs($verb, $this->verbs());
     }
 
     function isMyType($type) {
@@ -389,7 +389,7 @@ abstract class ActivityHandlerPlugin extends Plugin
         } elseif ($target instanceof Profile && $target->isLocal()) {
             $original = null;
             // FIXME: Shouldn't favorites show up with a 'target' activityobject?
-            if (!ActivityUtils::compareTypes($activity->verb, array(ActivityVerb::POST)) && isset($activity->objects[0])) {
+            if (!ActivityUtils::compareVerbs($activity->verb, array(ActivityVerb::POST)) && isset($activity->objects[0])) {
                 // If this is not a post, it's a verb targeted at something (such as a Favorite attached to a note)
                 if (!empty($activity->objects[0]->id)) {
                     $activity->context->replyToID = $activity->objects[0]->id;
@@ -413,7 +413,7 @@ abstract class ActivityHandlerPlugin extends Plugin
         $actor = $oactor->localProfile();
 
         // FIXME: will this work in all cases? I made it work for Favorite...
-        if (ActivityUtils::compareTypes($activity->verb, array(ActivityVerb::POST))) {
+        if (ActivityUtils::compareVerbs($activity->verb, array(ActivityVerb::POST))) {
             $object = $activity->objects[0];
         } else {
             $object = $activity;
index f3383efda5b4db936a75e8611a09147aa9a0cfc9..ef2e23224374b6a9ddd9629ef366e7f19ed0bdb7 100644 (file)
@@ -348,7 +348,7 @@ class ActivityUtils
         return null;
     }
 
-    static function compareTypes($type, $objects)    // this does verbs too!
+    static function compareTypes($type, $objects)
     {
         $type = self::resolveUri($type);
         foreach ((array)$objects as $object) {
@@ -359,6 +359,11 @@ class ActivityUtils
         return false;
     }
 
+    static function compareVerbs($type, $objects)
+    {
+        return self::compareTypes($type, $objects);
+    }
+
     static function resolveUri($uri, $make_relative=false)
     {
         if (empty($uri)) {
index eb73bbe43c9a4d40137688bea56894868c679bda..aa6cdc935962043dc43cae89c9ffe076d858d263 100644 (file)
@@ -527,8 +527,8 @@ class FavoritePlugin extends ActivityVerbHandlerPlugin
         $expected_verb = $exists ? ActivityVerb::UNFAVORITE : ActivityVerb::FAVORITE;
 
         switch (true) {
-        case $exists && ActivityUtils::compareTypes($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
-        case !$exists && ActivityUtils::compareTypes($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
+        case $exists && ActivityUtils::compareVerbs($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
+        case !$exists && ActivityUtils::compareVerbs($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
             common_redirect(common_local_url('activityverb',
                                 array('id'   => $target->getID(),
                                       'verb' => ActivityUtils::resolveUri($expected_verb, true))));
@@ -543,10 +543,10 @@ class FavoritePlugin extends ActivityVerbHandlerPlugin
     protected function doActionPost(ManagedAction $action, $verb, Notice $target, Profile $scoped)
     {
         switch (true) {
-        case ActivityUtils::compareTypes($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
+        case ActivityUtils::compareVerbs($verb, array(ActivityVerb::FAVORITE, ActivityVerb::LIKE)):
             Fave::addNew($scoped, $target);
             break;
-        case ActivityUtils::compareTypes($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
+        case ActivityUtils::compareVerbs($verb, array(ActivityVerb::UNFAVORITE, ActivityVerb::UNLIKE)):
             Fave::removeEntry($scoped, $target);
             break;
         default:
index ab78478db5e43f237a2e4c7ec1964acd42970b2e..f40efcf8abb82a089e1581807dcd324e4019aa2e 100644 (file)
@@ -357,7 +357,7 @@ class Fave extends Managed_DataObject
         $target = self::getTargetFromStored($stored);
 
         // The following logic was copied from StatusNet's Activity plugin
-        if (ActivityUtils::compareTypes($target->verb, array(ActivityVerb::POST))) {
+        if (ActivityUtils::compareVerbs($target->verb, array(ActivityVerb::POST))) {
             // "I like the thing you posted"
             $act->objects = $target->asActivity()->objects;
         } else {