Skip to content

Commit

Permalink
Use User->get_id
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Dec 19, 2024
1 parent cc40881 commit c625e82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion includes/class-mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Activitypub;

use Activitypub\Collection\Actors;
use Activitypub\Model\User;

/**
* Mailer Class.
Expand Down Expand Up @@ -152,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( \get_author_posts_url( $user_id ), (array) $activity['to'], true )
! in_array( ( new User( $user_id ) )->get_id(), (array) $activity['to'], true )
) {
return;
}
Expand Down
6 changes: 4 additions & 2 deletions tests/includes/class-test-mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Activitypub\Tests;

use Activitypub\Mailer;
use Activitypub\Model\User;
use Activitypub\Notification;
use WP_UnitTestCase;

Expand Down Expand Up @@ -312,7 +313,8 @@ 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 get_author_posts_url( $user_id );
return ( new User( $user_id ) )->get_id();

}
return $url;
};
Expand Down Expand Up @@ -406,7 +408,7 @@ public function test_direct_message_text( $text, $expected ) {
'object' => array(
'content' => $text,
),
'to' => array( get_author_posts_url( $user_id ) ),
'to' => array( ( new User( $user_id ) )->get_id() ),
);

// Mock remote metadata.
Expand Down

0 comments on commit c625e82

Please sign in to comment.