From 16944c50dd1f5f68d43f629c6a143b145fe695c8 Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Fri, 20 Dec 2024 10:54:10 +0100 Subject: [PATCH] Use Actors::get_by_id --- includes/class-mailer.php | 2 +- tests/includes/class-test-mailer.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/class-mailer.php b/includes/class-mailer.php index 5ab951b83..70acea9b3 100644 --- a/includes/class-mailer.php +++ b/includes/class-mailer.php @@ -153,7 +153,7 @@ public static function direct_message( $activity, $user_id ) { is_activity_public( $activity ) || // Only accept messages that have the user in the "to" field. empty( $activity['to'] ) || - ! in_array( ( new User( $user_id ) )->get_id(), (array) $activity['to'], true ) + ! in_array( Actors::get_by_id( $user_id )->get_id(), (array) $activity['to'], true ) ) { return; } diff --git a/tests/includes/class-test-mailer.php b/tests/includes/class-test-mailer.php index 6972def4c..f335889c5 100644 --- a/tests/includes/class-test-mailer.php +++ b/tests/includes/class-test-mailer.php @@ -8,7 +8,7 @@ namespace Activitypub\Tests; use Activitypub\Mailer; -use Activitypub\Model\User; +use Activitypub\Collection\Actors; use Activitypub\Notification; use WP_UnitTestCase; @@ -313,7 +313,7 @@ public function test_direct_message( $send_email, $activity ) { // We need to replace back in the user URL because the user_id is not available in the data provider. $replace = function ( $url ) use ( $user_id ) { if ( 'user_url' === $url ) { - return ( new User( $user_id ) )->get_id(); + return Actors::get_by_id( $user_id )->get_id(); } return $url; @@ -408,7 +408,7 @@ public function test_direct_message_text( $text, $expected ) { 'object' => array( 'content' => $text, ), - 'to' => array( ( new User( $user_id ) )->get_id() ), + 'to' => array( Actors::get_by_id( $user_id )->get_id() ), ); // Mock remote metadata.