add template to redirect activitypub requests for cached events
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Failing after 48s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Failing after 51s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m2s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m2s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m1s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 1m4s
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Successful in 1m0s
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Failing after 48s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Failing after 51s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m2s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m2s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m1s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 1m4s
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Successful in 1m0s
This commit is contained in:
parent
3f5c57134e
commit
be52d2705f
2 changed files with 29 additions and 0 deletions
|
@ -123,4 +123,32 @@ class Event_Sources {
|
||||||
// Return false if no application actor is found.
|
// Return false if no application actor is found.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the ActivityPub template for EventPrime.
|
||||||
|
*
|
||||||
|
* @param string $template The path to the template object.
|
||||||
|
* @return string The new path to the JSON template.
|
||||||
|
*/
|
||||||
|
public static function redirect_activitypub_requests_for_cached_external_events( $template ) {
|
||||||
|
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! \is_singular() ) {
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $post;
|
||||||
|
|
||||||
|
if ( 'gatherpress_event' !== $post->post_type ) {
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! str_starts_with( \get_site_url(), $post->guid ) ) {
|
||||||
|
\wp_safe_redirect( $post->guid, 301 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,7 @@ class Setup {
|
||||||
add_action( 'activitypub_register_handlers', array( Handler::class, 'register_handlers' ) );
|
add_action( 'activitypub_register_handlers', array( Handler::class, 'register_handlers' ) );
|
||||||
add_action( 'admin_init', array( User_Interface::class, 'init' ) );
|
add_action( 'admin_init', array( User_Interface::class, 'init' ) );
|
||||||
}
|
}
|
||||||
|
\add_filter( 'template_include', array( \Event_Bridge_For_ActivityPub\Event_Sources::class, 'redirect_activitypub_requests_for_cached_external_events' ), 100 );
|
||||||
|
|
||||||
add_filter( 'activitypub_transformer', array( $this, 'register_activitypub_event_transformer' ), 10, 3 );
|
add_filter( 'activitypub_transformer', array( $this, 'register_activitypub_event_transformer' ), 10, 3 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue