Skip to content
8 changes: 6 additions & 2 deletions includes/collection/class-following.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,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 ) ) {
Expand Down
Loading