| @@ -28,11 +28,8 @@ | ||
| 28 | 28 | * |
| 29 | 29 | * @see https://www.w3.org/TR/activitypub/#inbox |
| 30 | 30 | */ |
| 31 | 31 | class Inbox_Controller extends \WP_REST_Controller { |
| 32 | - use Verification; | |
| 33 | - use Language_Map; | |
| 34 | - | |
| 35 | 32 | /** |
| 36 | 33 | * The namespace of this controller's route. |
| 37 | 34 | * |
| 38 | 35 | * @var string |
| @@ -56,9 +53,9 @@ | ||
| 56 | 53 | array( |
| 57 | 54 | array( |
| 58 | 55 | 'methods' => \WP_REST_Server::CREATABLE, |
| 59 | 56 | 'callback' => array( $this, 'create_item' ), |
| 60 | - 'permission_callback' => array( $this, 'verify_signature' ), | |
| 57 | + 'permission_callback' => array( 'Activitypub\Rest\Server', 'verify_signature' ), | |
| 61 | 58 | 'args' => array( |
| 62 | 59 | 'id' => array( |
| 63 | 60 | 'description' => 'The unique identifier for the activity.', |
| 64 | 61 | 'type' => 'string', |
| @@ -71,21 +68,15 @@ | ||
| 71 | 68 | 'required' => true, |
| 72 | 69 | 'sanitize_callback' => '\Activitypub\object_to_uri', |
| 73 | 70 | ), |
| 74 | 71 | 'type' => array( |
| 75 | - 'description' => 'The type of the activity.', | |
| 76 | - 'type' => 'string', | |
| 77 | - 'required' => true, | |
| 78 | - 'sanitize_callback' => 'sanitize_html_class', | |
| 79 | - 'validate_callback' => static function ( $param ) { | |
| 80 | - // Reject values that sanitize to empty so dynamic hook names always have a suffix. | |
| 81 | - return '' !== \sanitize_html_class( (string) $param ); | |
| 82 | - }, | |
| 72 | + 'description' => 'The type of the activity.', | |
| 73 | + 'type' => 'string', | |
| 74 | + 'required' => true, | |
| 83 | 75 | ), |
| 84 | 76 | 'object' => array( |
| 85 | 77 | 'description' => 'The object of the activity.', |
| 86 | 78 | 'required' => true, |
| 87 | - 'sanitize_callback' => array( $this, 'localize_language_maps' ), | |
| 88 | 79 | 'validate_callback' => static function ( $param, $request, $key ) { |
| 89 | 80 | /** |
| 90 | 81 | * Filter the ActivityPub object validation. |
| 91 | 82 | * |
| @@ -161,9 +152,9 @@ | ||
| 161 | 152 | * @param null $user_id The user ID. |
| 162 | 153 | * @param string $type The type of the activity. |
| 163 | 154 | * @param Activity|\WP_Error $activity The Activity object. |
| 164 | 155 | */ |
| 165 | - \do_action( 'activitypub_rest_inbox_disallowed', $data, null, $type, $activity ); | |
| 156 | + do_action( 'activitypub_rest_inbox_disallowed', $data, null, $type, $activity ); | |
| 166 | 157 | } else { |
| 167 | 158 | $recipients = $this->get_local_recipients( $data ); |
| 168 | 159 | |
| 169 | 160 | // Filter out blocked recipients. |
| @@ -385,12 +376,8 @@ | ||
| 385 | 376 | |
| 386 | 377 | $recipients = extract_recipients_from_activity( $activity ); |
| 387 | 378 | |
| 388 | 379 | foreach ( $recipients as $recipient ) { |
| 389 | - // Skip public audience identifiers - they're not actual recipients to fetch. | |
| 390 | - if ( \in_array( $recipient, ACTIVITYPUB_PUBLIC_AUDIENCE_IDENTIFIERS, true ) ) { | |
| 391 | - continue; | |
| 392 | - } | |
| 393 | 380 | |
| 394 | 381 | if ( ! is_same_domain( $recipient ) ) { |
| 395 | 382 | $collection = Http::get_remote_object( $recipient ); |
| 396 | 383 | |
| @@ -416,17 +403,8 @@ | ||
| 416 | 403 | continue; |
| 417 | 404 | } |
| 418 | 405 | |
| 419 | 406 | $user_ids[] = $user_id; |
| 420 | - } | |
| 421 | - | |
| 422 | - // Check for an Actor in the Object field. | |
| 423 | - if ( empty( $user_ids ) && ! empty( $activity['object'] ) ) { | |
| 424 | - $user_id = Actors::get_id_by_resource( $activity['object'] ); | |
| 425 | - | |
| 426 | - if ( ! \is_wp_error( $user_id ) && user_can_activitypub( $user_id ) ) { | |
| 427 | - $user_ids[] = $user_id; | |
| 428 | - } | |
| 429 | 407 | } |
| 430 | 408 | |
| 431 | 409 | return array_unique( array_map( 'intval', $user_ids ) ); |
| 432 | 410 | } |