Register follow handler
This commit is contained in:
parent
7eda747b4f
commit
1e6d49f393
@ -7,6 +7,7 @@ namespace ActivityPub;
|
||||
use ActivityPub\Activities\AcceptHandler;
|
||||
use ActivityPub\Activities\CreateHandler;
|
||||
use ActivityPub\Activities\DeleteHandler;
|
||||
use ActivityPub\Activities\FollowHandler;
|
||||
use ActivityPub\Activities\NonActivityHandler;
|
||||
use ActivityPub\Activities\UpdateHandler;
|
||||
use ActivityPub\Activities\ValidationHandler;
|
||||
@ -87,6 +88,7 @@ class ActivityPub
|
||||
$dispatcher->addSubscriber( $this->module->get( CreateHandler::class ) );
|
||||
$dispatcher->addSubscriber( $this->module->get( UpdateHandler::class ) );
|
||||
$dispatcher->addSubscriber( $this->module->get( DeleteHandler::class ) );
|
||||
$dispatcher->addSubscriber( $this->module->get( FollowHandler::class ) );
|
||||
$dispatcher->addSubscriber( $this->module->get( AcceptHandler::class ) );
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,11 @@ class ActivityPubConfig
|
||||
*/
|
||||
private $idPathPrefix;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $autoAcceptsFollows;
|
||||
|
||||
/**
|
||||
* Don't call this directly - instead, use
|
||||
* ActivityPubConfig->createBuilder()->build()
|
||||
@ -51,6 +56,7 @@ class ActivityPubConfig
|
||||
$this->authFunction = $builder->getAuthFunction();
|
||||
$this->jsonLdContext = $builder->getJsonLdContext();
|
||||
$this->idPathPrefix = $builder->getIdPathPrefix();
|
||||
$this->autoAcceptsFollows = $builder->getAutoAcceptsFollows();
|
||||
}
|
||||
|
||||
public static function createBuilder()
|
||||
@ -106,5 +112,13 @@ class ActivityPubConfig
|
||||
{
|
||||
return $this->idPathPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getAutoAcceptsFollows()
|
||||
{
|
||||
return $this->autoAcceptsFollows;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,11 @@ class ActivityPubConfigBuilder
|
||||
*/
|
||||
private $idPathPrefix;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $autoAcceptsFollows;
|
||||
|
||||
/**
|
||||
* Creates a new ActivityPubConfig instance with default values
|
||||
*
|
||||
@ -67,6 +72,7 @@ class ActivityPubConfigBuilder
|
||||
};
|
||||
$this->jsonLdContext = ContextProvider::getDefaultContext();
|
||||
$this->idPathPrefix = IdProvider::DEFAULT_ID_PATH_PREFIX;
|
||||
$this->autoAcceptsFollows = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,5 +241,37 @@ class ActivityPubConfigBuilder
|
||||
$this->idPathPrefix = $idPathPrefix;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getAutoAcceptsFollows()
|
||||
{
|
||||
return $this->autoAcceptsFollows;
|
||||
}
|
||||
|
||||
/**
|
||||
* If `autoAcceptsFollows` is `true`, the library will automatically accept
|
||||
* incoming Follow activities instead of waiting to receive an Accept activity
|
||||
* from the local actor.
|
||||
*
|
||||
* Default: false
|
||||
*
|
||||
* Usage for this setter:
|
||||
*
|
||||
* $config->setAutoAcceptsFollows() // $autoAcceptsFollows will be true
|
||||
*
|
||||
* or
|
||||
*
|
||||
* $config->setAutoAcceptsFollows( $trueOrFalse ) // $autoAcceptsFollows will be the value of $trueOrFalse
|
||||
*
|
||||
* @param bool $autoAcceptsFollows [default: true]
|
||||
* @return ActivityPubConfigBuilder The builder instance
|
||||
*/
|
||||
public function setAutoAcceptsFollows( $autoAcceptsFollows = true )
|
||||
{
|
||||
$this->autoAcceptsFollows = $autoAcceptsFollows;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ namespace ActivityPub\Config;
|
||||
use ActivityPub\Activities\AcceptHandler;
|
||||
use ActivityPub\Activities\CreateHandler;
|
||||
use ActivityPub\Activities\DeleteHandler;
|
||||
use ActivityPub\Activities\FollowHandler;
|
||||
use ActivityPub\Activities\NonActivityHandler;
|
||||
use ActivityPub\Activities\UpdateHandler;
|
||||
use ActivityPub\Activities\ValidationHandler;
|
||||
@ -135,6 +136,10 @@ class ActivityPubModule
|
||||
->addArgument( new Reference( SimpleDateTimeProvider::class ) )
|
||||
->addArgument( new Reference( ObjectsService::class ) );
|
||||
|
||||
$this->injector->register( FollowHandler::class, FollowHandler::class )
|
||||
->addArgument( $config->getAutoAcceptsFollows() )
|
||||
->addArgument( new Reference( ContextProvider::class ) );
|
||||
|
||||
$this->injector->register( AcceptHandler::class, AcceptHandler::class )
|
||||
->addArgument( new Reference( ObjectsService::class ) )
|
||||
->addArgument( new Reference( CollectionsService::class ) )
|
||||
|
Loading…
Reference in New Issue
Block a user