From da059c0d7090906ef374f8e8cf171bd2b69b35f0 Mon Sep 17 00:00:00 2001
From: "Author: ruru4143" <ruru@event-federation.eu>
Date: Sat, 9 Dec 2023 02:02:25 +0100
Subject: [PATCH] started tribe plugin, working on smoother build process

---
 activitypub-event-transformers.php         |  4 +-
 activitypub/transformer/class-tribe.php    | 45 ++++++++++++++++++++++
 activitypub/transformer/class-vs-event.php |  1 +
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/activitypub-event-transformers.php b/activitypub-event-transformers.php
index cd2702c..18e9da6 100644
--- a/activitypub-event-transformers.php
+++ b/activitypub-event-transformers.php
@@ -29,8 +29,8 @@ if ( ! defined( 'ABSPATH' ) ) {
  * @return void
  */
 function register_event_transformers( $transformers_manager ) {
-	// require_once __DIR__ . '/activitypub/transformer/class-tribe.php';
-	// $transformers_manager->register( new \Tribe() );
+	require_once __DIR__ . '/activitypub/transformer/class-tribe.php';
+	$transformers_manager->register( new \Tribe() );
 
 	require_once __DIR__ . '/activitypub/transformer/class-vs-event.php';
 	$transformers_manager->register( new \VS_Event() );
diff --git a/activitypub/transformer/class-tribe.php b/activitypub/transformer/class-tribe.php
index 2211b3a..4b7d19d 100644
--- a/activitypub/transformer/class-tribe.php
+++ b/activitypub/transformer/class-tribe.php
@@ -66,4 +66,49 @@ class Tribe extends \Activitypub\Transformer\Base {
 	public static function get_supported_post_types() {
 		return array( 'tribe_events' );
 	}
+
+	/**
+	 * 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 transform() {
+		$object = new Event();
+
+		$this->set_timeformat( 'Y-m-d\TH:i:s\Z' );
+
+
+		$object
+			->set_id( $this->get_id() )
+			->set_url( $this->get_url() )
+			->set_external_participation_url( $this->get_url() )
+
+			->set_published( $this->get_published() )
+			->if( $this->get_updated() > $this->get_published() )
+			->set_updated( $this->get_updated() )
+
+			->set_attributed_to( $this->get_attributed_to() )
+			->set_content( $this->get_content() )
+			->set_content_map( $this->get_basic_content_map() ) // todo rename to basic
+
+			->set_summary( $this->get_post_meta( 'post_excerpt', true, $this->get_content() ) ) // todo second argument is fallback / default
+			->set_start_time( $this->get_post_meta_time( '_EventStartDateUTC' ) )
+			->set_end_time( $this->get_post_meta_time( '_EventEndDateUTC' ) )
+			->set_to( $this->get_followers_stream() )
+			// ->set_location( $this->get_event_location()->to_array())
+			->set_cc( $this->get_cc() )
+			->set_attachment( $this->get_attachments() )
+			->set_tag( $this->get_tags() )
+
+			->set_comments_enabled( $this->get_comments_open() )
+			->set_replies_moderation_option( 'allow_all' )
+			->set_join_mode( 'external' )
+			->set_status( 'CONFIRMED' )
+			->set_category( 'MEETING' );
+
+		assert( $object->get_type() === $this->get_object_type() );
+		return $object;
+	}
 }
diff --git a/activitypub/transformer/class-vs-event.php b/activitypub/transformer/class-vs-event.php
index be7d2eb..b7fedec 100644
--- a/activitypub/transformer/class-vs-event.php
+++ b/activitypub/transformer/class-vs-event.php
@@ -133,6 +133,7 @@ class VS_Event extends \Activitypub\Transformer\Base {
 	 * @return \Activitypub\Activity\Base_Object The ActivityPub Object.
 	 */
 	public function transform() {
+		// todo make tranform nicer
 		$context = Event::get_context();
 		$object  = new Event();
 		$object