From cc5f3b1e9f324e4a8f8c4aa6cf7c36b0c2e7dc78 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Tue, 14 May 2024 06:15:35 +0200 Subject: [PATCH] Relay the exclude_replies parameter to filters --- includes/class-mastodon-api.php | 4 ++-- includes/handler/class-handler.php | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/class-mastodon-api.php b/includes/class-mastodon-api.php index eb92e37..8fdbde9 100644 --- a/includes/class-mastodon-api.php +++ b/includes/class-mastodon-api.php @@ -2246,7 +2246,8 @@ public function api_account_statuses( $request ) { $user_id = $this->get_user_id_from_request( $request ); $args = array( - 'author' => $user_id, + 'author' => $user_id, + 'exclude_replies' => $request->get_param( 'exclude_replies' ), ); $args = apply_filters( 'mastodon_api_account_statuses_args', $args, $request ); @@ -2290,7 +2291,6 @@ public function api_account( $request ) { * ``` */ $account = \apply_filters( 'mastodon_api_account', null, $user_id, $request, null ); - return $this->validate_entity( $account, Entity\Account::class ); } diff --git a/includes/handler/class-handler.php b/includes/handler/class-handler.php index 761c31f..2602b76 100644 --- a/includes/handler/class-handler.php +++ b/includes/handler/class-handler.php @@ -115,6 +115,12 @@ protected function get_posts( $args, $min_id = null, $max_id = null ): \WP_REST_ continue; } + if ( $args['exclude_replies'] ) { + if ( $status->in_reply_to_id ) { + continue; + } + } + if ( ! $status->is_valid() ) { error_log( wp_json_encode( compact( 'status', 'post' ) ) ); continue;