diff --git a/includes/collection/class-users.php b/includes/collection/class-users.php index 62b4264..506722b 100644 --- a/includes/collection/class-users.php +++ b/includes/collection/class-users.php @@ -7,6 +7,8 @@ use Activitypub\Model\User; use Activitypub\Model\Blog_User; use Activitypub\Model\Application_User; +use function Activitypub\is_user_disabled; + class Users { /** * The ID of the Blog User @@ -34,6 +36,14 @@ class Users { $user_id = (int) $user_id; } + if ( is_user_disabled( $user_id ) ) { + return new WP_Error( + 'activitypub_user_not_found', + \__( 'User not found', 'activitypub' ), + array( 'status' => 404 ) + ); + } + if ( self::BLOG_USER_ID === $user_id ) { return Blog_User::from_wp_user( $user_id ); } elseif ( self::APPLICATION_USER_ID === $user_id ) { diff --git a/includes/functions.php b/includes/functions.php index 15a769e..9d2a03e 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -299,6 +299,11 @@ function is_user_disabled( $user_id ) { break; // if the user is any other user, it's enabled if it can publish posts. default: + if ( ! \get_user_by( 'id', $user_id ) ) { + $return = true; + break; + } + if ( defined( 'ACTIVITYPUB_DISABLE_USER' ) ) { $return = ACTIVITYPUB_DISABLE_USER; break; diff --git a/includes/model/class-user.php b/includes/model/class-user.php index d641497..23cd013 100644 --- a/includes/model/class-user.php +++ b/includes/model/class-user.php @@ -26,10 +26,7 @@ class User extends Actor { protected $type = 'Person'; public static function from_wp_user( $user_id ) { - if ( - is_user_disabled( $user_id ) || - ! get_user_by( 'id', $user_id ) - ) { + if ( is_user_disabled( $user_id ) ) { return new WP_Error( 'activitypub_user_not_found', \__( 'User not found', 'activitypub' ), diff --git a/includes/rest/class-inbox.php b/includes/rest/class-inbox.php index b530a37..98b4e55 100644 --- a/includes/rest/class-inbox.php +++ b/includes/rest/class-inbox.php @@ -124,7 +124,6 @@ class Inbox { * @return WP_REST_Response */ public static function user_inbox_post( $request ) { - $user_id = $request->get_param( 'user_id' ); $user = User_Collection::get_by_various( $user_id ); @@ -150,7 +149,6 @@ class Inbox { * @return WP_REST_Response */ public static function shared_inbox_post( $request ) { - $data = $request->get_params(); $type = $request->get_param( 'type' ); $users = self::extract_recipients( $data );