| @@ -11,9 +11,8 @@ | ||
| 11 | 11 | namespace Activitypub\Rest; |
| 12 | 12 | |
| 13 | 13 | use Activitypub\Collection\Remote_Actors; |
| 14 | 14 | use Activitypub\Http; |
| 15 | -use Activitypub\OAuth\Scope; | |
| 16 | 15 | use Activitypub\Webfinger; |
| 17 | 16 | |
| 18 | 17 | /** |
| 19 | 18 | * Proxy Controller. |
| @@ -49,18 +48,9 @@ | ||
| 49 | 48 | array( |
| 50 | 49 | array( |
| 51 | 50 | 'methods' => \WP_REST_Server::CREATABLE, |
| 52 | 51 | 'callback' => array( $this, 'create_item' ), |
| 53 | - | |
| 54 | - /* | |
| 55 | - * The Basic Profile puts `proxyUrl` under a read scope. The POST carries the | |
| 56 | - * target URL, and what this persists is a local cache of the remote object | |
| 57 | - * plus a rate-limit transient, not content attributed to the actor, so it is | |
| 58 | - * not a write in the sense `write` grants. | |
| 59 | - */ | |
| 60 | - 'permission_callback' => function ( $request ) { | |
| 61 | - return $this->verify_authentication( $request, Scope::READ ); | |
| 62 | - }, | |
| 52 | + 'permission_callback' => array( $this, 'verify_authentication' ), | |
| 63 | 53 | 'args' => array( |
| 64 | 54 | 'id' => array( |
| 65 | 55 | 'description' => 'The remote ActivityPub object to fetch: an HTTPS URL or an acct identifier (`user@host`, `@user@host`, or `acct:user@host`).', |
| 66 | 56 | 'type' => 'string', |
| @@ -195,21 +185,12 @@ | ||
| 195 | 185 | */ |
| 196 | 186 | $object = Http::get_remote_object( $url ); |
| 197 | 187 | |
| 198 | 188 | if ( \is_wp_error( $object ) ) { |
| 199 | - /* | |
| 200 | - * Pass on a status the remote actually returned, so a caller can tell a missing object | |
| 201 | - * from an unreachable host. `Http::get()` uses the response code as the error code; | |
| 202 | - * this method's own rejections use a string code and stay a 502, because a document we | |
| 203 | - * refused is not the caller's request being wrong. | |
| 204 | - */ | |
| 205 | - $code = $object->get_error_code(); | |
| 206 | - $status = \is_numeric( $code ) ? (int) $code : 0; | |
| 207 | - | |
| 208 | 189 | return new \WP_Error( |
| 209 | 190 | 'activitypub_fetch_failed', |
| 210 | 191 | \__( 'Failed to fetch the remote object.', 'activitypub' ), |
| 211 | - array( 'status' => $status ?: 502 ) | |
| 192 | + array( 'status' => 502 ) | |
| 212 | 193 | ); |
| 213 | 194 | } |
| 214 | 195 | |
| 215 | 196 | $response = new \WP_REST_Response( $object, 200 ); |