From 5a74aa4a4dfb3ee94b80ec7ba5856339070de4b4 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 12 Mar 2019 22:19:51 +0100 Subject: [PATCH] simplified "followers" endpoint --- includes/db/class-followers.php | 2 +- includes/rest/class-followers.php | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/includes/db/class-followers.php b/includes/db/class-followers.php index 5c9545c..cd1ed84 100644 --- a/includes/db/class-followers.php +++ b/includes/db/class-followers.php @@ -12,7 +12,7 @@ class Followers { $followers = get_user_option( 'activitypub_followers', $author_id ); if ( ! $followers ) { - return $followers; + return array(); } foreach ( $followers as $key => $follower ) { diff --git a/includes/rest/class-followers.php b/includes/rest/class-followers.php index 4a12404..403393d 100644 --- a/includes/rest/class-followers.php +++ b/includes/rest/class-followers.php @@ -62,15 +62,9 @@ class Followers { $json->{'@context'} = \Activitypub\get_context(); - $followers = \Activitypub\Db\Followers::get_followers( $user_id ); - - if ( ! is_array( $followers ) ) { - $followers = array(); - } - $json->partOf = get_rest_url( null, "/activitypub/1.0/users/$user_id/followers" ); // phpcs:ignore - $json->totalItems = count( $followers ); // phpcs:ignore - $json->orderedItems = $followers; // phpcs:ignore + $json->totalItems = \Activitypub\count_followers( $user_id ); // phpcs:ignore + $json->orderedItems = \Activitypub\Db\Followers::get_followers( $user_id ); // phpcs:ignore $json->first = $json->partOf; // phpcs:ignore