updated plugin ActivityPub version 3.3.3

This commit is contained in:
2024-10-09 12:44:17 +00:00
committed by Gitium
parent fb4b27bbc6
commit c54fa007bd
106 changed files with 7070 additions and 2918 deletions

View File

@ -19,8 +19,8 @@ use Activitypub\Activity\Base_Object;
class Event extends Base_Object {
// Human friendly minimal context for full Mobilizon compatible ActivityPub events.
const JSON_LD_CONTEXT = array(
'https://schema.org/', // The base context is schema.org, cause it is used a lot.
'https://www.w3.org/ns/activitystreams', // The ActivityStreams context overrides everyting also defined in schema.org.
'https://schema.org/', // The base context is schema.org, because it is used a lot.
'https://www.w3.org/ns/activitystreams', // The ActivityStreams context overrides everything also defined in schema.org.
array( // The keys here override/extend the context even more.
'pt' => 'https://joinpeertube.org/ns#',
'mz' => 'https://joinmobilizon.org/ns#',
@ -51,6 +51,7 @@ class Event extends Base_Object {
/**
* Mobilizon compatible values for repliesModertaionOption.
*
* @var array
*/
const REPLIES_MODERATION_OPTION_TYPES = array( 'allow_all', 'closed' );
@ -58,10 +59,11 @@ class Event extends Base_Object {
/**
* Mobilizon compatible values for joinModeTypes.
*/
const JOIN_MODE_TYPES = array( 'free', 'restricted', 'external' ); // and 'invite', but not used by mobilizon atm
const JOIN_MODE_TYPES = array( 'free', 'restricted', 'external' ); // and 'invite', but not used by mobilizon atm.
/**
* Allowed values for ical VEVENT STATUS.
*
* @var array
*/
const ICAL_EVENT_STATUS_TYPES = array( 'TENTATIVE', 'CONFIRMED', 'CANCELLED' );
@ -70,6 +72,7 @@ class Event extends Base_Object {
* Default event categories.
*
* These values currently reflect the default set as proposed by Mobilizon to maximize interoperability.
*
* @var array
*/
const DEFAULT_EVENT_CATEGORIES = array(
@ -106,8 +109,7 @@ class Event extends Base_Object {
);
/**
* Event is an implementation of one of the
* Activity Streams
* Event is an implementation of one of the Activity Streams.
*
* @var string
*/
@ -115,11 +117,13 @@ class Event extends Base_Object {
/**
* The Title of the event.
*
* @var string
*/
protected $name;
/**
* The events contacts
* The events contacts.
*
* @context {
* '@id' => 'mz:contacts',
@ -142,12 +146,16 @@ class Event extends Base_Object {
protected $comments_enabled;
/**
* Timezone of the event.
*
* @context https://joinmobilizon.org/ns#timezone
* @var string
*/
protected $timezone;
/**
* Moderation option for replies.
*
* @context https://joinmobilizon.org/ns#repliesModerationOption
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#repliesmoderation
* @var string
@ -155,6 +163,8 @@ class Event extends Base_Object {
protected $replies_moderation_option;
/**
* Whether anonymous participation is enabled.
*
* @context https://joinmobilizon.org/ns#anonymousParticipationEnabled
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#anonymousparticipationenabled
* @var bool
@ -162,26 +172,34 @@ class Event extends Base_Object {
protected $anonymous_participation_enabled;
/**
* The event's category.
*
* @context https://schema.org/category
* @var enum
* @var string
*/
protected $category;
/**
* Language of the event.
*
* @context https://schema.org/inLanguage
* @var
* @var string
*/
protected $in_language;
/**
* Whether the event is online.
*
* @context https://joinmobilizon.org/ns#isOnline
* @var bool
*/
protected $is_online;
/**
* The event's status.
*
* @context https://www.w3.org/2002/12/cal/ical#status
* @var enum
* @var string
*/
protected $status;
@ -196,25 +214,33 @@ class Event extends Base_Object {
protected $actor;
/**
* The external participation URL.
*
* @context https://joinmobilizon.org/ns#externalParticipationUrl
* @var string
*/
protected $external_participation_url;
/**
* Indicator of how new members may be able to join.
*
* @context https://joinmobilizon.org/ns#joinMode
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#joinmode
* @var
* @var string
*/
protected $join_mode;
/**
* The participant count of the event.
*
* @context https://joinmobilizon.org/ns#participantCount
* @var int
*/
protected $participant_count;
/**
* How many places there can be for an event.
*
* @context https://schema.org/maximumAttendeeCapacity
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#maximumattendeecapacity
* @var int
@ -222,6 +248,8 @@ class Event extends Base_Object {
protected $maximum_attendee_capacity;
/**
* The number of attendee places for an event that remain unallocated.
*
* @context https://schema.org/remainingAttendeeCapacity
* @see https://docs.joinmobilizon.org/contribute/activity_pub/#remainignattendeecapacity
* @var int
@ -234,6 +262,7 @@ class Event extends Base_Object {
* The passed timezone is only set when it is a valid one, otherwise the site's timezone is used.
*
* @param string $timezone The timezone string to be set, e.g. 'Europe/Berlin'.
* @return Event
*/
public function set_timezone( $timezone ) {
if ( in_array( $timezone, timezone_identifiers_list(), true ) ) {
@ -246,14 +275,16 @@ class Event extends Base_Object {
}
/**
* Custom setter for repliesModerationOption which also directy sets commentsEnabled accordingly.
* Custom setter for repliesModerationOption which also directly sets commentsEnabled accordingly.
*
* @param string $type
* @param string $type The type of the replies moderation option.
*
* @return Event
*/
public function set_replies_moderation_option( $type ) {
if ( in_array( $type, self::REPLIES_MODERATION_OPTION_TYPES, true ) ) {
$this->replies_moderation_option = $type;
$this->comments_enabled = ( 'allow_all' === $type ) ? true : false;
$this->comments_enabled = ( 'allow_all' === $type ) ? true : false;
} else {
_doing_it_wrong(
__METHOD__,
@ -268,11 +299,13 @@ class Event extends Base_Object {
/**
* Custom setter for commentsEnabled which also directly sets repliesModerationOption accordingly.
*
* @param bool $comments_enabled
* @param bool $comments_enabled Whether comments are enabled.
*
* @return Event
*/
public function set_comments_enabled( $comments_enabled ) {
if ( is_bool( $comments_enabled ) ) {
$this->comments_enabled = $comments_enabled;
$this->comments_enabled = $comments_enabled;
$this->replies_moderation_option = $comments_enabled ? 'allow_all' : 'closed';
} else {
_doing_it_wrong(
@ -288,7 +321,9 @@ class Event extends Base_Object {
/**
* Custom setter for the ical status that checks whether the status is an ical event status.
*
* @param string $status
* @param string $status The status of the event.
*
* @return Event
*/
public function set_status( $status ) {
if ( in_array( $status, self::ICAL_EVENT_STATUS_TYPES, true ) ) {
@ -309,8 +344,10 @@ class Event extends Base_Object {
*
* Falls back to Mobilizons default category.
*
* @param string $category
* @param bool $mobilizon_compatibilty Whether the category must be compatibly with Mobilizon.
* @param string $category The category of the event.
* @param bool $mobilizon_compatibilty Optional. Whether the category must be compatibly with Mobilizon. Default true.
*
* @return Event
*/
public function set_category( $category, $mobilizon_compatibilty = true ) {
if ( $mobilizon_compatibilty ) {
@ -327,12 +364,14 @@ class Event extends Base_Object {
*
* Automatically sets the joinMode to true if called.
*
* @param string $url
* @param string $url The URL for external participation.
*
* @return Event
*/
public function set_external_participation_url( $url ) {
if ( preg_match( '/^https?:\/\/.*/i', $url ) ) {
$this->external_participation_url = $url;
$this->join_mode = 'external';
$this->join_mode = 'external';
}
return $this;