rename known_users, known_actor to clarify scope

This commit is contained in:
Django Doucet 2023-11-13 11:05:17 -07:00
parent a1e4cdf379
commit 0d1f7628d4
2 changed files with 8 additions and 8 deletions

View file

@ -34,7 +34,7 @@ class Application {
return array_unique( array_filter( $follower_inboxes_all ) ); return array_unique( array_filter( $follower_inboxes_all ) );
} }
public static function known_users() { public static function known_commenters() {
// at this point we just need known_commenters // at this point we just need known_commenters
// this could get expensive though, eventually it would make sense // this could get expensive though, eventually it would make sense
// to schedule an add comment_author_url on Follow to a known_users site option // to schedule an add comment_author_url on Follow to a known_users site option
@ -49,11 +49,11 @@ class Application {
) )
); );
$comment_query = new WP_Comment_Query( $args ); $comment_query = new WP_Comment_Query( $args );
$known_users_all = []; $known_commenters_all = [];
foreach ( $comment_query->comments as $user ) { foreach ( $comment_query->comments as $user ) {
$known_users_all[] = $user->comment_author_url; $known_commenters_all[] = $user->comment_author_url;
} }
return array_unique( array_filter( $known_users_all ) ); return array_unique( array_filter( $known_commenters_all ) );
} }
public static function is_actor_delete_request( $request ) { public static function is_actor_delete_request( $request ) {
@ -64,9 +64,9 @@ class Application {
return false; return false;
} }
public static function is_known_actor( $request ) { public static function is_known_commenter( $request ) {
$json = $request->get_params( 'JSON' ); $json = $request->get_params( 'JSON' );
if ( in_array( $json['actor'], self::known_users() ) ) { if ( in_array( $json['actor'], self::known_commenters() ) ) {
return $json['actor']; return $json['actor'];
} }
return false; return false;

View file

@ -110,7 +110,7 @@ class Server {
if ( 'GET' !== $request->get_method() ) { if ( 'GET' !== $request->get_method() ) {
if ( Application::is_actor_delete_request( $request ) ) { if ( Application::is_actor_delete_request( $request ) ) {
if ( ! Application::is_known_actor( $request ) ) { if ( ! Application::is_known_commenter( $request ) ) {
return $response; return $response;
} }
} }
@ -119,7 +119,7 @@ class Server {
if ( \is_wp_error( $verified_request ) ) { if ( \is_wp_error( $verified_request ) ) {
$error_code = $verified_request->get_error_code(); $error_code = $verified_request->get_error_code();
if ( Application::is_actor_delete_request( $request ) && '404' === $error_code ) { if ( Application::is_actor_delete_request( $request ) && '404' === $error_code ) {
$actor = Application::is_known_actor( $request ); $actor = Application::is_known_commenter( $request );
if ( wp_http_validate_url( $actor ) ) { if ( wp_http_validate_url( $actor ) ) {
\wp_schedule_single_event( \wp_schedule_single_event(
\time(), \time(),