2020-02-21 11:11:03 +01:00
|
|
|
<?php
|
|
|
|
namespace Activitypub\Rest;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom (hopefully temporary) ActivityPub Rest Server
|
|
|
|
*
|
|
|
|
* @author Matthias Pfefferle
|
|
|
|
*/
|
|
|
|
class Server extends \WP_REST_Server {
|
|
|
|
/**
|
|
|
|
* Overwrite dispatch function to quick fix missing subtype featur
|
|
|
|
*
|
|
|
|
* @see https://core.trac.wordpress.org/ticket/49404
|
|
|
|
*
|
|
|
|
* @param WP_REST_Request $request Request to attempt dispatching.
|
|
|
|
* @return WP_REST_Response Response returned by the callback.
|
|
|
|
*/
|
|
|
|
public function dispatch( $request ) {
|
|
|
|
$content_type = $request->get_content_type();
|
|
|
|
|
2020-07-21 09:23:35 +02:00
|
|
|
if ( ! $content_type ) {
|
|
|
|
return parent::dispatch( $request );
|
|
|
|
}
|
|
|
|
|
2020-02-21 11:11:03 +01:00
|
|
|
// check for content-sub-types like 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
|
2020-02-22 13:02:58 +01:00
|
|
|
if ( \preg_match( '/application\/([a-zA-Z+_-]+\+)json/', $content_type['value'] ) ) {
|
2022-02-28 23:52:30 +01:00
|
|
|
// Signature Verification requires headers to be intact
|
2020-02-21 11:11:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// make request filterable
|
2020-05-12 20:30:06 +02:00
|
|
|
$request = \apply_filters( 'activitypub_pre_dispatch_request', $request );
|
2020-02-21 11:11:03 +01:00
|
|
|
|
|
|
|
return parent::dispatch( $request );
|
|
|
|
}
|
|
|
|
}
|