From e91e76bf1734c01217e203b1e8b25ee7c988bcad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sun, 3 Dec 2023 11:41:13 +0100 Subject: [PATCH] add ical_status --- activitypub/object/class-event.php | 21 +++++++++++---------- activitypub/transformer/class-vs-event.php | 3 ++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/activitypub/object/class-event.php b/activitypub/object/class-event.php index daba673..4740930 100644 --- a/activitypub/object/class-event.php +++ b/activitypub/object/class-event.php @@ -130,6 +130,7 @@ class Event extends \Activitypub\Activity\Base_Object { private function rename_ical_status_key( $array ) { $array[ 'ical:status' ] = $array[ 'icalStatus' ]; unset( $array[ 'icalStatus' ] ); + return $array; } /** @@ -137,7 +138,7 @@ class Event extends \Activitypub\Activity\Base_Object { */ public function rename_array_keys( $array ) { if ( isset( $array[ 'icalStatus' ] ) ) { - $array = rename_ical_status_key( $array ); + $array = $this->rename_ical_status_key( $array ); } return $array; } @@ -170,21 +171,21 @@ class Event extends \Activitypub\Activity\Base_Object { } public function filter_context( $context ) { - if ( isset( $this->replies_moderation_option ) ) { - $replies_moderation_option_context = $this->get_property_context( 'replies_moderation_option' ); - } + // if ( isset( $this->replies_moderation_option ) ) { + // $replies_moderation_option_context = $this->get_property_context( 'replies_moderation_option' ); + // } return $context; } private static function compact_context( $key_context, $namespace, $abbreviation ) { $abbreviation_added = false; foreach ( $key_context as $key => $value ) { - // Check if the key starts with "https://joinpeertube.org/" + // Check if the key starts with the namespace if ( strpos( $value, $namespace ) === 0 ) { // Replace the key - $key_context[ $key ] = $abbreviation . ':' . substr($value, strlen( $namespace )); + $key_context[ $key ] = $abbreviation . ':' . substr( $value, strlen( $namespace ) ); - // Add "pt" element only once + // Add abbreviation element for the namespace only once if ( ! $abbreviation_added ) { $key_context = [ $abbreviation => $namespace . '/ns#' ] + $key_context; $abbreviation_added = true; @@ -198,9 +199,9 @@ class Event extends \Activitypub\Activity\Base_Object { $class = self::class; $transient = "activitypub_context_object_{$class}"; $context = get_transient($transient); - if ( $context ) { - return $context; - } + // if ( $context ) { + // return $context; + // } $reflection_class = new ReflectionClass( self::class ); $context = array( 'https://www.w3.org/ns/activitystreams', diff --git a/activitypub/transformer/class-vs-event.php b/activitypub/transformer/class-vs-event.php index 6df06b0..872fd62 100644 --- a/activitypub/transformer/class-vs-event.php +++ b/activitypub/transformer/class-vs-event.php @@ -188,7 +188,8 @@ class VS_Event extends \Activitypub\Transformer\Base { ->set_tag( $this->get_tags() ) ->set_replies_moderation_option( 'allow_all' ) ->set_join_mode( 'external' ) - ->set_external_participation_url( $this->get_url() ); + ->set_external_participation_url( $this->get_url() ) + ->set_ical_status( 'CONFIRMED' ); return $object; }