Functions should return quickly (cosmetic)

...rather than have long if statements encapsuling everything.
This commit is contained in:
Mikael Nordfeldth 2014-05-05 19:05:05 +02:00
parent 2ea5f00666
commit 30f4f5606c

View File

@ -254,11 +254,11 @@ abstract class MicroAppPlugin extends Plugin
*/
function onNoticeDeleteRelated($notice)
{
if ($this->isMyNotice($notice)) {
$this->deleteRelated($notice);
if (!$this->isMyNotice($notice)) {
return true;
}
return true;
$this->deleteRelated($notice);
}
/**
@ -339,12 +339,12 @@ abstract class MicroAppPlugin extends Plugin
*/
function onStartActivityObjectFromNotice($notice, &$object)
{
if ($this->isMyNotice($notice)) {
$object = $this->activityObjectFromNotice($notice);
return false;
if (!$this->isMyNotice($notice)) {
return true;
}
return true;
$object = $this->activityObjectFromNotice($notice);
return false;
}
/**
@ -357,7 +357,9 @@ abstract class MicroAppPlugin extends Plugin
*/
function onStartHandleFeedEntryWithProfile($activity, $oprofile, &$notice)
{
if ($this->isMyActivity($activity)) {
if (!$this->isMyActivity($activity)) {
return true;
}
$actor = $oprofile->checkAuthorship($activity);
@ -379,9 +381,6 @@ abstract class MicroAppPlugin extends Plugin
return false;
}
return true;
}
/**
* Handle a posted object from Salmon
*
@ -393,7 +392,10 @@ abstract class MicroAppPlugin extends Plugin
function onStartHandleSalmonTarget($activity, $target)
{
if ($this->isMyActivity($activity)) {
if (!$this->isMyActivity($activity)) {
return true;
}
$this->log(LOG_INFO, "Checking {$activity->id} as a valid Salmon slap.");
if ($target instanceof User_group) {
@ -407,8 +409,7 @@ abstract class MicroAppPlugin extends Plugin
$uri = $target->uri;
$original = null;
if (!empty($activity->context->replyToID)) {
$original = Notice::getKV('uri',
$activity->context->replyToID);
$original = Notice::getKV('uri', $activity->context->replyToID);
}
if (!array_key_exists($uri, $activity->context->attention) &&
(empty($original) ||
@ -437,9 +438,6 @@ abstract class MicroAppPlugin extends Plugin
return false;
}
return true;
}
/**
* Handle object posted via AtomPub
*
@ -451,7 +449,9 @@ abstract class MicroAppPlugin extends Plugin
*/
function onStartAtomPubNewActivity(&$activity, $user, &$notice)
{
if ($this->isMyActivity($activity)) {
if (!$this->isMyActivity($activity)) {
return true;
}
$options = array('source' => 'atompub');
@ -463,9 +463,6 @@ abstract class MicroAppPlugin extends Plugin
return false;
}
return true;
}
/**
* Handle object imported from a backup file
*
@ -479,7 +476,9 @@ abstract class MicroAppPlugin extends Plugin
*/
function onStartImportActivity($user, $author, $activity, $trusted, &$done)
{
if ($this->isMyActivity($activity)) {
if (!$this->isMyActivity($activity)) {
return true;
}
$obj = $activity->objects[0];
@ -499,9 +498,6 @@ abstract class MicroAppPlugin extends Plugin
return false;
}
return true;
}
/**
* Event handler gives the plugin a chance to add custom
* Atom XML ActivityStreams output from a previously filled-out