get__id(); // Save follower. $follower = Followers::add_follower( $user_id, $activity['actor'] ); /** * Fires after a new follower has been added. * * @param string $actor The URL of the actor (follower) who initiated the follow. * @param array $activity The complete activity data of the follow request. * @param int $user_id The ID of the WordPress user being followed. * @param \Activitypub\Model\Follower|\WP_Error $follower The Follower object containing the new follower's data. */ do_action( 'activitypub_followers_post_follow', $activity['actor'], $activity, $user_id, $follower ); // Send notification. $notification = new Notification( 'follow', $activity['actor'], $activity, $user_id ); $notification->send(); } /** * Send Accept response. * * @param string $actor The Actor URL. * @param array $activity_object The Activity object. * @param int $user_id The ID of the WordPress User. * @param \Activitypub\Model\Follower|\WP_Error $follower The Follower object. */ public static function queue_accept( $actor, $activity_object, $user_id, $follower ) { if ( \is_wp_error( $follower ) ) { // Impossible to send a "Reject" because we can not get the Remote-Inbox. return; } // Only send minimal data. $activity_object = array_intersect_key( $activity_object, array_flip( array( 'id', 'type', 'actor', 'object', ) ) ); $activity = new Activity(); $activity->set_type( 'Accept' ); $activity->set_actor( Actors::get_by_id( $user_id )->get_id() ); $activity->set_object( $activity_object ); $activity->set_to( array( $actor ) ); add_to_outbox( $activity, null, $user_id, ACTIVITYPUB_CONTENT_VISIBILITY_PRIVATE ); } }