WIP: Add Event Sources Logic (ActivityPub follows) #86

Draft
linos wants to merge 36 commits from event_sources into main
2 changed files with 29 additions and 0 deletions
Showing only changes of commit be52d2705f - Show all commits

View file

@ -123,4 +123,32 @@ class Event_Sources {
// Return false if no application actor is found.
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;
}
}

View file

@ -216,6 +216,7 @@ class Setup {
add_action( 'activitypub_register_handlers', array( Handler::class, 'register_handlers' ) );
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 );
}