diff --git a/lib/activity.php b/lib/activity.php index 2d3930df0d..4db3b9ff4e 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -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]); } diff --git a/lib/activityhandlerplugin.php b/lib/activityhandlerplugin.php index 529749cc1d..6639e27822 100644 --- a/lib/activityhandlerplugin.php +++ b/lib/activityhandlerplugin.php @@ -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; diff --git a/lib/activityutils.php b/lib/activityutils.php index f3383efda5..ef2e232243 100644 --- a/lib/activityutils.php +++ b/lib/activityutils.php @@ -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)) { diff --git a/plugins/Favorite/FavoritePlugin.php b/plugins/Favorite/FavoritePlugin.php index eb73bbe43c..aa6cdc9359 100644 --- a/plugins/Favorite/FavoritePlugin.php +++ b/plugins/Favorite/FavoritePlugin.php @@ -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: diff --git a/plugins/Favorite/classes/Fave.php b/plugins/Favorite/classes/Fave.php index ab78478db5..f40efcf8ab 100644 --- a/plugins/Favorite/classes/Fave.php +++ b/plugins/Favorite/classes/Fave.php @@ -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 {