From 8f4f7a1cffc1386ae2efe9b6188dc3a52d7dd0b8 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 12 Mar 2019 23:14:50 -0400 Subject: [PATCH] Handle object being either a string or an array --- includes/server/inbox.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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;