add testing snippets and merging the latest versions
Some checks failed
Deploy to https://wordpress-test.event-federation.eu/ / deploy (push) Failing after 7s
Some checks failed
Deploy to https://wordpress-test.event-federation.eu/ / deploy (push) Failing after 7s
This commit is contained in:
parent
649075c424
commit
014b2e1171
6 changed files with 123 additions and 63 deletions
|
@ -37,3 +37,30 @@ function register_event_transformers( $transformers_manager ) {
|
|||
}
|
||||
|
||||
add_action( 'activitypub_transformers_register', 'register_event_transformers' );
|
||||
|
||||
|
||||
|
||||
// TODO Below here is temporary code needed to do local testing atm.
|
||||
|
||||
// Add a filter for http_request_host_is_external
|
||||
add_filter( 'http_request_host_is_external', 'custom_http_request_host_is_external', 10, 3 );
|
||||
|
||||
// Your custom callback function
|
||||
function custom_http_request_host_is_external( $is_external, $host, $url ) {
|
||||
$is_external = true;
|
||||
|
||||
return $is_external;
|
||||
}
|
||||
|
||||
// add_filter( 'rest_request_before_callbacks', 'change_relay_actor_to_blog_actor', 10, 3 );
|
||||
|
||||
// function change_relay_actor_to_blog_actor( $response, $handler, $request ) {
|
||||
|
||||
// }
|
||||
|
||||
// add_filters( 'https_ssl_verify', 'dont_verify_local_dev_https', 10, 3);
|
||||
|
||||
|
||||
// function dont_verify_local_dev_https($url) {
|
||||
// return false;
|
||||
// }
|
||||
|
|
|
@ -18,9 +18,9 @@ require_once __DIR__ . '/class-place.php';
|
|||
*/
|
||||
class Event extends \Activitypub\Activity\Base_Object {
|
||||
// todo maybe rename to mobilizon event?
|
||||
const REPLIES_MODERATION_OPTION_TYPES = [ 'allow_all', 'closed' ];
|
||||
const JOIN_MODE_TYPES = [ 'free', 'restricted', 'external' ]; // amd 'invite', but not used by mobilizon atm
|
||||
const ICAL_EVENT_STATUS_TYPES = ["TENTATIVE", "CONFIRMED", "CANCELLED"];
|
||||
const REPLIES_MODERATION_OPTION_TYPES = array( 'allow_all', 'closed' );
|
||||
const JOIN_MODE_TYPES = array( 'free', 'restricted', 'external' ); // amd 'invite', but not used by mobilizon atm
|
||||
const ICAL_EVENT_STATUS_TYPES = array( 'TENTATIVE', 'CONFIRMED', 'CANCELLED' );
|
||||
|
||||
/**
|
||||
* Event is an implementation of one of the
|
||||
|
@ -30,6 +30,10 @@ class Event extends \Activitypub\Activity\Base_Object {
|
|||
*/
|
||||
protected $type = 'Event';
|
||||
|
||||
protected $name;
|
||||
|
||||
protected $contacts;
|
||||
|
||||
/**
|
||||
* Extension invented by PeerTube whether comments/replies are <enabled>
|
||||
* Mobilizon also implemented this as a fallback to their own
|
||||
|
@ -81,7 +85,7 @@ class Event extends \Activitypub\Activity\Base_Object {
|
|||
protected $is_online;
|
||||
|
||||
/**
|
||||
* @context http://www.w3.org/2002/12/cal/ical#status
|
||||
* @context https://www.w3.org/2002/12/cal/ical#status
|
||||
* @var enum
|
||||
*/
|
||||
protected $status;
|
||||
|
@ -112,6 +116,13 @@ class Event extends \Activitypub\Activity\Base_Object {
|
|||
*/
|
||||
protected $maximum_attendee_capacity;
|
||||
|
||||
/**
|
||||
* @context https://schema.org/remainingAttendeeCapacity
|
||||
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#remainignattendeecapacity
|
||||
* @var int
|
||||
*/
|
||||
protected $remaining_attendee_capacity;
|
||||
|
||||
|
||||
/**
|
||||
* Get the context information for a property.
|
||||
|
@ -150,7 +161,7 @@ class Event extends \Activitypub\Activity\Base_Object {
|
|||
|
||||
// Add abbreviation element for the namespace only once
|
||||
if ( ! $abbreviation_added ) {
|
||||
$key_context = [ $abbreviation => $namespace ] + $key_context;
|
||||
$key_context = array( $abbreviation => $namespace ) + $key_context;
|
||||
$abbreviation_added = true;
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +182,7 @@ class Event extends \Activitypub\Activity\Base_Object {
|
|||
'https://w3id.org/security/v1',
|
||||
);
|
||||
|
||||
$key_context = [];
|
||||
$key_context = array();
|
||||
|
||||
foreach ( $reflection_class->getProperties() as $property ) {
|
||||
$doc_omment = $property->getDocComment();
|
||||
|
@ -188,7 +199,7 @@ class Event extends \Activitypub\Activity\Base_Object {
|
|||
'https://joinpeertube.org/ns#' => 'pt',
|
||||
'https://joinmobilizon.org/ns#' => 'mz',
|
||||
'https://schema.org/' => 'sc',
|
||||
'http://www.w3.org/2002/12/cal/ical#' => 'ical',
|
||||
'https://www.w3.org/2002/12/cal/ical#' => 'ical',
|
||||
);
|
||||
|
||||
foreach ( $namespace_abbreviations as $namespace => $abbreviation ) {
|
||||
|
|
|
@ -26,26 +26,36 @@ class Place extends \Activitypub\Activity\Base_Object {
|
|||
protected $type = 'Place';
|
||||
|
||||
/**
|
||||
* Indicates the accuracy of position coordinates on a Place objects.
|
||||
* Expressed in properties of percentage. e.g. "94.0" means "94.0% accurate".
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-accuracy
|
||||
* @var float
|
||||
* @var float xsd:float [>= 0.0f, <= 100.0f]
|
||||
*/
|
||||
protected $accuracy;
|
||||
|
||||
/**
|
||||
* Indicates the altitude of a place. The measurement units is indicated using the units property.
|
||||
* If units is not specified, the default is assumed to be "m" indicating meters.
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-altitude
|
||||
* @var float
|
||||
* @var float xsd:float
|
||||
*/
|
||||
protected $altitude;
|
||||
|
||||
/**
|
||||
* The latitude of a place.
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-latitude
|
||||
* @var float
|
||||
* @var float xsd:float
|
||||
*/
|
||||
protected $latitude;
|
||||
|
||||
/**
|
||||
* The longitude of a place.
|
||||
*
|
||||
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-longitude
|
||||
* @var float
|
||||
* @var float xsd:float
|
||||
*/
|
||||
protected $longitude;
|
||||
|
||||
|
|
|
@ -168,9 +168,11 @@ class Tribe extends \Activitypub\Transformer\Base {
|
|||
return ( new Place() )
|
||||
->set_type( 'Place' )
|
||||
->set_name( $venue->post_name )
|
||||
->set_address( $venue->address . "\n" .
|
||||
$venue->zip . ", " . $venue->city . "\n" .
|
||||
$venue->country ); // todo add checks that everything exists here (lol)
|
||||
->set_address(
|
||||
$venue->address . "\n" .
|
||||
$venue->zip . ', ' . $venue->city . "\n" .
|
||||
$venue->country
|
||||
); // todo add checks that everything exists here (lol)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -100,12 +100,12 @@ class VS_Event extends \Activitypub\Transformer\Base {
|
|||
private function get_event_link() {
|
||||
$event_link = get_post_meta( $this->wp_post->ID, 'event-link', true );
|
||||
if ( $event_link ) {
|
||||
return [
|
||||
return array(
|
||||
'type' => 'Link',
|
||||
'name' => 'Website',
|
||||
'href' => \esc_url( get_post_meta( $post_id, 'event-location', true ) ),
|
||||
'href' => \esc_url( $event_link ),
|
||||
'mediaType' => 'text/html',
|
||||
];
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,8 @@ class VS_Event extends \Activitypub\Transformer\Base {
|
|||
*/
|
||||
protected function get_attachments() {
|
||||
$attachments = parent::get_attachments();
|
||||
$attachments[0]['type'] = 'Document';
|
||||
$attachments[0]['name'] = 'Banner';
|
||||
$event_link = $this->get_event_link();
|
||||
if ( $event_link ) {
|
||||
$attachments[] = $this->get_event_link();
|
||||
|
@ -121,10 +123,6 @@ class VS_Event extends \Activitypub\Transformer\Base {
|
|||
return $attachments;
|
||||
}
|
||||
|
||||
private function get_category() {
|
||||
return 'MEETING';
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the VS Event WP_Post object to an ActivityPub Event Object.
|
||||
*
|
||||
|
@ -160,7 +158,7 @@ class VS_Event extends \Activitypub\Transformer\Base {
|
|||
if ( $summary ) {
|
||||
$object->set_summary( $summary );
|
||||
} else {
|
||||
$object->set_summary( $this->content );
|
||||
$object->set_summary( $this->get_content() );
|
||||
}
|
||||
|
||||
$start_time = get_post_meta( $this->wp_post->ID, 'event-start-date', true );
|
||||
|
@ -183,14 +181,26 @@ class VS_Event extends \Activitypub\Transformer\Base {
|
|||
get_rest_url_by_path( $path ),
|
||||
)
|
||||
)
|
||||
->set_cc( $this->get_cc() )
|
||||
->set_cc( array( get_rest_url_by_path( $path ) ) )
|
||||
->set_attachment( $this->get_attachments() )
|
||||
->set_tag( $this->get_tags() )
|
||||
->set_replies_moderation_option( 'allow_all' )
|
||||
->set_join_mode( 'external' )
|
||||
->set_external_participation_url( $this->get_url() )
|
||||
->set_status( 'CONFIRMED' )
|
||||
->set_category( 'MEETING' );
|
||||
->set_category( 'MEETING' )
|
||||
->set_contacts( array() )
|
||||
->set_name( get_the_title( $this->wp_post->ID ) )
|
||||
->set_timezone( 'Europe/Vienna' )
|
||||
->set_is_online( false )
|
||||
->set_in_language( 'de ' )
|
||||
->set_actor( $this->get_attributed_to() );
|
||||
|
||||
$object->set_remaining_attendee_capacity( null )
|
||||
->set_anonymous_participation_enabled( null )
|
||||
->set_draft( false );
|
||||
$object->set_participant_count( 2 );
|
||||
$object->set_uuid( '1de96701-bceb-4a78-bc18-6c417f52b314' );
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue