diff --git a/includes/activitypub/handler/class-create.php b/includes/activitypub/handler/class-create.php index 10e0864..9a860f4 100644 --- a/includes/activitypub/handler/class-create.php +++ b/includes/activitypub/handler/class-create.php @@ -70,6 +70,6 @@ class Create { return; } - $transmogrifier->save( $activity['object'] ); + $transmogrifier->save( $activity['object'], $activity['actor'] ); } } diff --git a/includes/activitypub/handler/class-update.php b/includes/activitypub/handler/class-update.php index e106641..a1a6372 100644 --- a/includes/activitypub/handler/class-update.php +++ b/includes/activitypub/handler/class-update.php @@ -42,7 +42,6 @@ class Update { } // Check that we are actually following this actor. - if ( ! Event_Sources::actor_is_event_source( $activity['actor'] ) ) { return; } @@ -67,6 +66,6 @@ class Update { return; } - $transmogrifier->save( $activity['object'] ); + $transmogrifier->save( $activity['object'], $activity['actor'] ); } } diff --git a/includes/activitypub/model/class-event-source.php b/includes/activitypub/model/class-event-source.php index 494024d..f676146 100644 --- a/includes/activitypub/model/class-event-source.php +++ b/includes/activitypub/model/class-event-source.php @@ -97,7 +97,7 @@ class Event_Source extends Actor { * Get the Event Source by the ActivityPub ID. * * @param string $actor_id The ActivityPub actor ID. - * @return Event_Source|false The Event Source Actor, if a WordPress Post representing it is found, false otherwise. + * @return Event_Source|WP_Error|false The Event Source Actor, if a WordPress Post representing it is found, false otherwise. */ public static function get_by_id( $actor_id ) { $post = self::get_wp_post_by_activitypub_actor_id( $actor_id ); diff --git a/includes/activitypub/transmogrifier/class-base.php b/includes/activitypub/transmogrifier/class-base.php index 9a720c1..d85f878 100644 --- a/includes/activitypub/transmogrifier/class-base.php +++ b/includes/activitypub/transmogrifier/class-base.php @@ -26,7 +26,7 @@ defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore */ abstract class Base { /** - * The current GatherPress Event object. + * The current Event object. * * @var Event */ @@ -40,11 +40,12 @@ abstract class Base { abstract protected function save_event(); /** - * Save the ActivityPub event object as GatherPress Event. + * Save the ActivityPub event object within WordPress. * - * @param array $activitypub_event The ActivityPub event as associative array. + * @param array $activitypub_event The ActivityPub event as associative array. + * @param ?string $actor The ActivityPub ID of the actor which we received the event from. */ - public function save( $activitypub_event ) { + public function save( $activitypub_event, $actor ) { $activitypub_event = Event::init_from_array( $activitypub_event ); if ( is_wp_error( $activitypub_event ) ) { @@ -57,6 +58,7 @@ abstract class Base { if ( $post_id ) { update_post_meta( $post_id, '_event_bridge_for_activitypub_is_remote_cached', true ); + update_post_meta( $post_id, '_event_bridge_for_activitypub_event_source', sanitize_url( $actor ) ); update_post_meta( $post_id, 'activitypub_content_visibility', constant( 'ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL' ) ?? '' ); } }