actions test
Some checks failed
Deploy to https://wordpress-test.event-federation.eu/ / deploy (push) Failing after 16s

This commit is contained in:
André Menrath 2023-11-25 12:05:12 +01:00
parent 9685b8f18c
commit 731a7f9691
4 changed files with 84 additions and 11 deletions

View file

@ -17,7 +17,6 @@ jobs:
uses: https://code.forgejo.org/actions/checkout@v4 uses: https://code.forgejo.org/actions/checkout@v4
- name: Install SSH Key - name: Install SSH Key
uses: webfactory/ssh-agent@v0.8.0
run: echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa run: echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
- name: Deploy via Rsync - name: Deploy via Rsync

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Plugin Name: ActivityPub Event Transformers for Events * Plugin Name: ActivityPub Transformers for Events
* Description: Custom ActivityPub Transformers for Events * Description: Custom ActivityPub Transformers for Events
* Plugin URI: https://event-federation.eu/ * Plugin URI: https://event-federation.eu/
* Version: 1.0.0 * Version: 1.0.0
@ -25,15 +25,19 @@ if ( ! defined( 'ABSPATH' ) ) {
* @return void * @return void
*/ */
function register_event_transformers( $transformers_manager ) { function register_event_transformers( $transformers_manager ) {
if ( is_plugin_active( 'the-events-calendar/the-events-calendar.php' ) ) { // if ( ! function_exists( 'is_plugin_active' ) ) {
require_once __DIR__ . '/activitypub/transformer/tribe.php'; // require_once __DIR__ . '/wp-admin/includes/plugin.php';
$transformers_manager->register( new \Tribe() ); // }
}
if ( is_plugin_active( 'vsel/vsel.php' ) ) { // if ( is_plugin_active( 'the-events-calendar/the-events-calendar.php' ) ) {
// require_once __DIR__ . '/activitypub/transformer/tribe.php';
// $transformers_manager->register( new \Tribe() );
// }
// if ( is_plugin_active( 'vsel/vsel.php' ) ) {
require_once __DIR__ . '/activitypub/transformer/vs-event.php'; require_once __DIR__ . '/activitypub/transformer/vs-event.php';
$transformers_manager->register( new \VS_Event() ); $transformers_manager->register( new \VS_Event() );
} // }
} }
add_action( 'activitypub_transformers_register', 'register_event_transformers' ); add_action( 'activitypub_transformers_register', 'register_event_transformers' );

View file

@ -20,7 +20,7 @@ class Tribe extends \Activitypub\Transformer\Base {
* @return string Widget name. * @return string Widget name.
*/ */
public function get_name() { public function get_name() {
return 'activitypub-tribe/tribe'; return 'activitypub-event-transformers/tribe';
} }
/** /**

View file

@ -1,4 +1,7 @@
<?php <?php
use Activitypub\Activity\Base_Object;
use function Activitypub\get_rest_url_by_path;
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly. exit; // Exit if accessed directly.
} }
@ -8,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* *
* @since 1.0.0 * @since 1.0.0
*/ */
class Tribe extends \Activitypub\Transformer\Base { class VS_Event extends \Activitypub\Transformer\Base {
/** /**
* Get widget name. * Get widget name.
@ -63,8 +66,75 @@ class Tribe extends \Activitypub\Transformer\Base {
/** /**
* Get the event location * Get the event location
*/ */
public function get_event_location() { public function get_event_location( $post_id ) {
$object = new Base_Object();
$object->set_type( 'Place' );
$object->set_name( get_post_meta( $post_id, 'event-location', true ) );
$array = $object->to_array();
return $array;
}
/**
* Transforms the VS Event WP_Post object to an ActivityPub Event Object
*
* @see \Activitypub\Activity\Base_Object
*
* @return \Activitypub\Activity\Base_Object The ActivityPub Object
*/
public function to_object() {
$wp_post = $this->wp_post;
$object = new Base_Object();
$object->set_id( $this->get_id() );
$object->set_url( $this->get_url() );
$object->set_type( $this->get_object_type() );
$published = \strtotime( $wp_post->post_date_gmt );
$object->set_published( \gmdate( 'Y-m-d\TH:i:s\Z', $published ) );
$updated = \strtotime( $wp_post->post_modified_gmt );
if ( $updated > $published ) {
$object->set_updated( \gmdate( 'Y-m-d\TH:i:s\Z', $updated ) );
}
$object->set_attributed_to( $this->get_attributed_to() );
$object->set_content( $this->get_content() );
$object->set_content_map( $this->get_content_map );
$summary = get_post_meta( $wp_post->ID, 'event-summary', true );
if ( $summary ) {
$object->set_summary( $summary );
} else {
$object->set_summary( $this->content );
}
$start_time = get_post_meta( $wp_post->ID, 'event-start-date', true );
$object->set_start_time( \gmdate( 'Y-m-d\TH:i:s\Z', $start_time ) );
$end_time = get_post_meta( $wp_post->ID, 'event-date', true );
$object->set_end_time( \gmdate( 'Y-m-d\TH:i:s\Z', $end_time ) );
$path = sprintf( 'users/%d/followers', intval( $wp_post->post_author ) );
$location = get_post_meta( $wp_post->ID, 'event-link', true );
$object->set_location( $this->get_event_location( $wp_post->ID ) );
$object->set_to(
array(
'https://www.w3.org/ns/activitystreams#Public',
get_rest_url_by_path( $path ),
)
);
$object->set_cc( $this->get_cc() );
$attachments = $this->get_attachments();
$object->set_attachment( $this->get_attachments() );
$object->set_tag( $this->get_tags() );
return $object;
} }
} }