wordpress-event-bridge-for-.../includes/activitypub/handler/class-accept.php
André Menrath b5a199fe9c
All checks were successful
PHP Code Checker / PHP Code Checker (pull_request) Successful in 53s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Successful in 1m10s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m11s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m10s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 1m7s
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Successful in 1m3s
cleanup and enhancement of documentation
2024-12-16 17:36:23 +01:00

49 lines
1.1 KiB
PHP

<?php
/**
* Accept handler file.
*
* @package Event_Bridge_For_ActivityPub
* @since 1.0.0
* @license AGPL-3.0-or-later */
namespace Event_Bridge_For_ActivityPub\ActivityPub\Handler;
use Activitypub\Collection\Actors;
/**
* Handle Accept requests.
*/
class Accept {
/**
* Initialize the class, registering the handler for incoming `Accept` activities to the ActivityPub plugin.
*/
public static function init() {
\add_action(
'activitypub_inbox_accept',
array( self::class, 'handle_accept' )
);
}
/**
* Handle incoming "Accept" activities.
*
* @param array $activity The activity object.
*/
public static function handle_accept( $activity ) {
if ( ! isset( $activity['object'] ) ) {
return;
}
$object = Actors::get_by_resource( $activity['object'] );
if ( ! $object || is_wp_error( $object ) ) {
// If we can not find a actor, we handle the `Accept` activity.
return;
}
// We only expect `Accept` activities being answers to follow requests by the application actor.
if ( Actors::BLOG_USER_ID !== $object->get__id() ) {
return;
}
}
}