diff --git a/includes/server/inbox.php b/includes/server/inbox.php index 46cf0a3..90ed630 100644 --- a/includes/server/inbox.php +++ b/includes/server/inbox.php @@ -9,6 +9,8 @@ When an Activity is received (i.e. POSTed) to an Actor's inbox, the server must: */ namespace pterotype\inbox; +use function pterotype\util\dereference_object; + require_once plugin_dir_path( __FILE__ ) . 'objects.php'; require_once plugin_dir_path( __FILE__ ) . 'deliver.php'; require_once plugin_dir_path( __FILE__ ) . 'collections.php'; @@ -93,7 +95,7 @@ function forward_activity( $actor_slug, $activity ) { } // Don't forward activities whose objects are actors if ( array_key_exists( 'object', $activity ) && - array_key_exists( 'publicKey', $activity['object'] ) ) { + is_actor( $activity['object'] ) ) { return; } if ( !references_local_object( $activity, 0 ) ) { @@ -109,6 +111,14 @@ function forward_activity( $actor_slug, $activity ) { \pterotype\deliver\deliver_activity( $actor_slug, $activity, false ); } +function is_actor( $object ) { + $object = dereference_object( $object ); + if ( ! $object || is_wp_error( $object) ) { + return false; + } + return array_key_exists( 'publicKey', $object ); +} + function references_local_object( $object, $depth ) { if ( $depth === 12 ) { return false;