400 ) ); } } elseif ( is_quote_activity( $activity ) ) { // TODO: Handle quotes differently. return false; } return self::create_post( $activity, $user_id, $visibility ); } /** * Handle outgoing post from local actor. * * Creates a WordPress post. The scheduler will add it to the outbox. * * @param array $activity The activity data. * @param int $user_id The local user ID. * @param string|null $visibility Content visibility. * * @return \WP_Post|\WP_Error The created post on success, WP_Error on failure. */ private static function create_post( $activity, $user_id, $visibility ) { $post = Posts::create( $activity, $user_id, $visibility ); if ( \is_wp_error( $post ) ) { return $post; } /** * Fires after a post has been created from an outgoing Create activity. * * @param int $post_id The created post ID. * @param array $activity The activity data. * @param int $user_id The user ID. * @param string $visibility The content visibility. */ \do_action( 'activitypub_outbox_created_post', $post->ID, $activity, $user_id, $visibility ); return $post; } /** * Handle outgoing reply from local actor. * * Creates a WordPress comment on the local post. The comment scheduler * will add it to the outbox and federate it. * * @param array $activity The activity data. * @param int $user_id The local user ID. * * @return \WP_Comment|false Comment on success, false if not a local reply. */ private static function create_comment( $activity, $user_id ) { $result = Interactions::add_comment( $activity, $user_id ); if ( ! $result ) { return false; } return \get_comment( $result ); } }