Call it compareVerbs when comparing verbs
This commit is contained in:
parent
404d5781fc
commit
9ad9b91efb
@ -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]);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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:
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user