diff --git a/includes/collection/class-following.php b/includes/collection/class-following.php index c0d8b3e56..6aa6b0408 100644 --- a/includes/collection/class-following.php +++ b/includes/collection/class-following.php @@ -60,7 +60,7 @@ class Following { * @param \WP_Post|int $post The ID of the remote Actor. * @param int $user_id The ID of the WordPress User. * - * @return int|false|\WP_Post|\WP_Error The Outbox ID or false on failure, the Actor post or a WP_Error. + * @return \WP_Post|\WP_Error The Actor post or a WP_Error. */ public static function follow( $post, $user_id ) { $post = \get_post( $post ); @@ -88,7 +88,11 @@ public static function follow( $post, $user_id ) { $follow->set_object( $post->guid ); $follow->set_to( array( $post->guid ) ); - return add_to_outbox( $follow, null, $user_id, ACTIVITYPUB_CONTENT_VISIBILITY_PRIVATE ); + $id = add_to_outbox( $follow, null, $user_id, ACTIVITYPUB_CONTENT_VISIBILITY_PRIVATE ); + + if ( ! $id || \is_wp_error( $id ) ) { + return new \WP_Error( 'activitypub_follow_failed', 'Failed to add follow to outbox' ); + } } return $post; diff --git a/includes/functions.php b/includes/functions.php index c1b2cabbf..3534279d0 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1545,7 +1545,7 @@ function add_to_outbox( $data, $activity_type = null, $user_id = 0, $content_vis * @param string|int $remote_actor The Actor URL, WebFinger Resource or Post-ID of the remote Actor. * @param int $user_id The ID of the WordPress User. * - * @return int|false|\WP_Post|\WP_Error The Outbox ID or false on failure, the Actor post or a WP_Error. + * @return \WP_Post|\WP_Error The Actor post or a WP_Error. */ function follow( $remote_actor, $user_id ) { if ( \is_numeric( $remote_actor ) ) {