| 1 |
<?php |
| 2 |
/** |
| 3 |
* Inspired by the PHP ActivityPub Library by @Landrok |
| 4 |
* |
| 5 |
* @link https://github.com/landrok/activitypub |
| 6 |
* |
| 7 |
* @package Activitypub |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace Activitypub\Activity; |
| 11 |
|
| 12 |
use Activitypub\Activity\Extended_Object\Place; |
| 13 |
|
| 14 |
/** |
| 15 |
* Base_Object is an implementation of one of the |
| 16 |
* Activity Streams Core Types. |
| 17 |
* |
| 18 |
* The Object is the primary base type for the Activity Streams |
| 19 |
* vocabulary. |
| 20 |
* |
| 21 |
* Note: Object is a reserved keyword in PHP. It has been suffixed with |
| 22 |
* 'Base_' for this reason. |
| 23 |
* |
| 24 |
* @see https://www.w3.org/TR/activitystreams-core/#object |
| 25 |
* |
| 26 |
* @method array|string|null get_attachment() Gets the attachment property of the object. |
| 27 |
* @method array|string|null get_attributed_to() Gets the entity attributed as the original author. |
| 28 |
* @method string|null get_audience() Gets the total population of entities for which the object can be considered relevant. |
| 29 |
* @method string[]|string|null get_bcc() Gets the private secondary audience of the object. |
| 30 |
* @method string[]|string|null get_bto() Gets the private primary audience of the object. |
| 31 |
* @method string[]|string|null get_cc() Gets the secondary recipients of the object. |
| 32 |
* @method string|null get_content() Gets the content property of the object. |
| 33 |
* @method string[]|null get_content_map() Gets the content map property of the object. |
| 34 |
* @method string|null get_context() Gets the context within which the object exists. |
| 35 |
* @method array|null get_dcterms() Gets the Dublin Core terms property of the object. |
| 36 |
* @method string|null get_duration() Gets the duration property of time-bound resources. |
| 37 |
* @method string|null get_end_time() Gets the date and time describing the ending time of the object. |
| 38 |
* @method string|null get_generator() Gets the entity that generated the object. |
| 39 |
* @method string[]|null get_icon() Gets the icon property of the object. |
| 40 |
* @method string|null get_id() Gets the object's unique global identifier. |
| 41 |
* @method string[]|null get_image() Gets the image property of the object. |
| 42 |
* @method string[]|string|null get_in_reply_to() Gets the objects this object is in reply to. |
| 43 |
* @method array|null get_interaction_policy() Gets the interaction policy property of the object. |
| 44 |
* @method array|null get_likes() Gets the collection of likes for this object. |
| 45 |
* @method array|string|null|Place get_location() Gets the physical or logical locations associated with the object. |
| 46 |
* @method string|null get_media_type() Gets the MIME media type of the content property. |
| 47 |
* @method string|null get_name() Gets the natural language name of the object. |
| 48 |
* @method string[]|null get_name_map() Gets the name map property of the object. |
| 49 |
* @method string|null get_preview() Gets the entity that provides a preview of this object. |
| 50 |
* @method string|null get_published() Gets the date and time the object was published in ISO 8601 format. |
| 51 |
* @method string|null get_quote() Gets the quote property of the object (FEP-044f). |
| 52 |
* @method string|null get_quote_url() Gets the quoteUrl property of the object. |
| 53 |
* @method string|null get_quote_uri() Gets the quoteUri property of the object. |
| 54 |
* @method string|null get__misskey_quote() Gets the _misskey_quote property of the object. |
| 55 |
* @method string|array|null get_replies() Gets the collection of responses to this object. |
| 56 |
* @method bool|null get_sensitive() Gets the sensitive property of the object. |
| 57 |
* @method array|null get_shares() Gets the collection of shares for this object. |
| 58 |
* @method array|null get_source() Gets the source property indicating content markup derivation. |
| 59 |
* @method string|null get_start_time() Gets the date and time describing the starting time of the object. |
| 60 |
* @method string|null get_summary() Gets the natural language summary of the object. |
| 61 |
* @method string[]|null get_summary_map() Gets the summary map property of the object. |
| 62 |
* @method array[]|null get_tag() Gets the tag property of the object. |
| 63 |
* @method string[]|string|null get_to() Gets the primary recipients of the object. |
| 64 |
* @method string get_type() Gets the type of the object. |
| 65 |
* @method string|null get_updated() Gets the date and time the object was updated in ISO 8601 format. |
| 66 |
* @method string|null get_url() Gets the URL of the object. |
| 67 |
* @method string|null get_former_type() Gets the former type of a Tombstone object. |
| 68 |
* @method string|null get_deleted() Gets the date and time the object was deleted in ISO 8601 format. |
| 69 |
* |
| 70 |
* @method string|string[] add_cc( string|array $cc ) Adds one or more entities to the secondary audience of the object. |
| 71 |
* @method string|string[] add_to( string|array $to ) Adds one or more entities to the primary audience of the object. |
| 72 |
* |
| 73 |
* @method Base_Object set_attachment( array $attachment ) Sets the attachment property of the object. |
| 74 |
* @method Base_Object set_attributed_to( string $attributed_to ) Sets the entity attributed as the original author. |
| 75 |
* @method Base_Object set_audience( string $audience ) Sets the total population of entities for which the object can be considered relevant. |
| 76 |
* @method Base_Object set_bcc( array|string $bcc ) Sets the private secondary audience of the object. |
| 77 |
* @method Base_Object set_bto( array|string $bto ) Sets the private primary audience of the object. |
| 78 |
* @method Base_Object set_cc( array|string $cc ) Sets the secondary recipients of the object. |
| 79 |
* @method Base_Object set_content( string $content ) Sets the content property of the object. |
| 80 |
* @method Base_Object set_content_map( array $content_map ) Sets the content property of the object. |
| 81 |
* @method Base_Object set_context( string $context ) Sets the context within which the object exists. |
| 82 |
* @method Base_Object set_dcterms( array $dcterms ) Sets the Dublin Core terms property of the object. |
| 83 |
* @method Base_Object set_duration( string $duration ) Sets the duration property of time-bound resources. |
| 84 |
* @method Base_Object set_end_time( string $end_time ) Sets the date and time describing the ending time of the object. |
| 85 |
* @method Base_Object set_generator( string $generator ) Sets the entity that generated the object. |
| 86 |
* @method Base_Object set_icon( array $icon ) Sets the icon property of the object. |
| 87 |
* @method Base_Object set_id( string $id ) Sets the object's unique global identifier. |
| 88 |
* @method Base_Object set_image( array $image ) Sets the image property of the object. |
| 89 |
* @method Base_Object set_in_reply_to( string|string[] $in_reply_to ) Sets the is in reply to property of the object. |
| 90 |
* @method Base_Object set_interaction_policy( array|null $policy ) Sets the interaction policy property of the object. |
| 91 |
* @method Base_Object set_likes( array $likes ) Sets the collection of likes for this object. |
| 92 |
* @method Base_Object set_location( array|string|Place $location ) Sets the physical or logical locations associated with the object. |
| 93 |
* @method Base_Object set_media_type( string $media_type ) Sets the MIME media type of the content property. |
| 94 |
* @method Base_Object set_name( string $name ) Sets the natural language name of the object. |
| 95 |
* @method Base_Object set_name_map( array|null $name_map ) Sets the name map property of the object. |
| 96 |
* @method Base_Object set_preview( string $preview ) Sets the entity that provides a preview of this object. |
| 97 |
* @method Base_Object set_published( string|null $published ) Sets the date and time the object was published in ISO 8601 format. |
| 98 |
* @method Base_Object set_quote( string $quote ) Sets the quote property of the object (FEP-044f). |
| 99 |
* @method Base_Object set_quote_url( string $quote_url ) Sets the quoteUrl property of the object. |
| 100 |
* @method Base_Object set_quote_uri( string $quote_uri ) Sets the quoteUri property of the object. |
| 101 |
* @method Base_Object set__misskey_quote( mixed $misskey_quote ) Sets the _misskey_quote property of the object. |
| 102 |
* @method Base_Object set_replies( string|array $replies ) Sets the collection of responses to this object. |
| 103 |
* @method Base_Object set_sensitive( bool|null $sensitive ) Sets the sensitive property of the object. |
| 104 |
* @method Base_Object set_shares( array $shares ) Sets the collection of shares for this object. |
| 105 |
* @method Base_Object set_source( array $source ) Sets the source property indicating content markup derivation. |
| 106 |
* @method Base_Object set_start_time( string $start_time ) Sets the date and time describing the starting time of the object. |
| 107 |
* @method Base_Object set_summary( string $summary ) Sets the natural language summary of the object. |
| 108 |
* @method Base_Object set_summary_map( array|null $summary_map ) Sets the summary property of the object. |
| 109 |
* @method Base_Object set_tag( array|null $tag ) Sets the tag property of the object. |
| 110 |
* @method Base_Object set_to( string|string[] $to ) Sets the primary recipients of the object. |
| 111 |
* @method Base_Object set_type( string $type ) Sets the type of the object. |
| 112 |
* @method Base_Object set_updated( string $updated ) Sets the date and time the object was updated in ISO 8601 format. |
| 113 |
* @method Base_Object set_url( string $url ) Sets the URL of the object. |
| 114 |
* @method Base_Object set_former_type( string $former_type ) Sets the former type of a Tombstone object. |
| 115 |
* @method Base_Object set_deleted( string $deleted ) Sets the date and time the object was deleted in ISO 8601 format. |
| 116 |
*/ |
| 117 |
class Base_Object extends Generic_Object { |
| 118 |
/** |
| 119 |
* The JSON-LD context for the object. |
| 120 |
* |
| 121 |
* @var array |
| 122 |
*/ |
| 123 |
const JSON_LD_CONTEXT = array( |
| 124 |
'https://www.w3.org/ns/activitystreams', |
| 125 |
array( |
| 126 |
'Hashtag' => 'as:Hashtag', |
| 127 |
'sensitive' => 'as:sensitive', |
| 128 |
'dcterms' => 'http://purl.org/dc/terms/', |
| 129 |
'gts' => 'https://gotosocial.org/ns#', |
| 130 |
'schema' => 'http://schema.org/', |
| 131 |
'exifData' => 'schema:exifData', |
| 132 |
'PropertyValue' => 'schema:PropertyValue', |
| 133 |
'interactionPolicy' => array( |
| 134 |
'@id' => 'gts:interactionPolicy', |
| 135 |
'@type' => '@id', |
| 136 |
), |
| 137 |
'canQuote' => array( |
| 138 |
'@id' => 'gts:canQuote', |
| 139 |
'@type' => '@id', |
| 140 |
), |
| 141 |
'canReply' => array( |
| 142 |
'@id' => 'gts:canReply', |
| 143 |
'@type' => '@id', |
| 144 |
), |
| 145 |
'canLike' => array( |
| 146 |
'@id' => 'gts:canLike', |
| 147 |
'@type' => '@id', |
| 148 |
), |
| 149 |
'canAnnounce' => array( |
| 150 |
'@id' => 'gts:canAnnounce', |
| 151 |
'@type' => '@id', |
| 152 |
), |
| 153 |
'automaticApproval' => array( |
| 154 |
'@id' => 'gts:automaticApproval', |
| 155 |
'@type' => '@id', |
| 156 |
), |
| 157 |
'manualApproval' => array( |
| 158 |
'@id' => 'gts:manualApproval', |
| 159 |
'@type' => '@id', |
| 160 |
), |
| 161 |
'always' => array( |
| 162 |
'@id' => 'gts:always', |
| 163 |
'@type' => '@id', |
| 164 |
), |
| 165 |
'toot' => 'http://joinmastodon.org/ns#', |
| 166 |
'blurhash' => 'toot:blurhash', |
| 167 |
), |
| 168 |
); |
| 169 |
|
| 170 |
/** |
| 171 |
* The default types for Objects. |
| 172 |
* |
| 173 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#object-types |
| 174 |
* |
| 175 |
* @var array |
| 176 |
*/ |
| 177 |
const TYPES = array( |
| 178 |
'Article', |
| 179 |
'Audio', |
| 180 |
'Document', |
| 181 |
'Event', |
| 182 |
'Image', |
| 183 |
'Note', |
| 184 |
'Page', |
| 185 |
'Place', |
| 186 |
'Profile', |
| 187 |
'Relationship', |
| 188 |
'Tombstone', |
| 189 |
'Video', |
| 190 |
); |
| 191 |
|
| 192 |
/** |
| 193 |
* The type of the object. |
| 194 |
* |
| 195 |
* @var string |
| 196 |
*/ |
| 197 |
protected $type = 'Object'; |
| 198 |
|
| 199 |
/** |
| 200 |
* A resource attached or related to an object that potentially |
| 201 |
* requires special handling. |
| 202 |
* The intent is to provide a model that is at least semantically |
| 203 |
* similar to attachments in email. |
| 204 |
* |
| 205 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attachment |
| 206 |
* |
| 207 |
* @var string|null |
| 208 |
*/ |
| 209 |
protected $attachment; |
| 210 |
|
| 211 |
/** |
| 212 |
* One or more entities to which this object is attributed. |
| 213 |
* The attributed entities might not be Actors. For instance, an |
| 214 |
* object might be attributed to the completion of another activity. |
| 215 |
* |
| 216 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attributedto |
| 217 |
* |
| 218 |
* @var string|null |
| 219 |
*/ |
| 220 |
protected $attributed_to; |
| 221 |
|
| 222 |
/** |
| 223 |
* One or more entities that represent the total population of |
| 224 |
* entities for which the object can be considered to be relevant. |
| 225 |
* |
| 226 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-audience |
| 227 |
* |
| 228 |
* @var string|null |
| 229 |
*/ |
| 230 |
protected $audience; |
| 231 |
|
| 232 |
/** |
| 233 |
* The content or textual representation of the Object encoded as a |
| 234 |
* JSON string. By default, the value of content is HTML. |
| 235 |
* The mediaType property can be used in the object to indicate a |
| 236 |
* different content type. |
| 237 |
* |
| 238 |
* The content MAY be expressed using multiple language-tagged |
| 239 |
* values. |
| 240 |
* |
| 241 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content |
| 242 |
* |
| 243 |
* @var string|null |
| 244 |
*/ |
| 245 |
protected $content; |
| 246 |
|
| 247 |
/** |
| 248 |
* The context within which the object exists or an activity was |
| 249 |
* performed. |
| 250 |
* The notion of "context" used is intentionally vague. |
| 251 |
* The intended function is to serve as a means of grouping objects |
| 252 |
* and activities that share a common originating context or |
| 253 |
* purpose. An example could be all activities relating to a common |
| 254 |
* project or event. |
| 255 |
* |
| 256 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-context |
| 257 |
* |
| 258 |
* @var string|null |
| 259 |
*/ |
| 260 |
protected $context; |
| 261 |
|
| 262 |
/** |
| 263 |
* The content MAY be expressed using multiple language-tagged |
| 264 |
* values. |
| 265 |
* |
| 266 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content |
| 267 |
* |
| 268 |
* @var array|null |
| 269 |
*/ |
| 270 |
protected $content_map; |
| 271 |
|
| 272 |
/** |
| 273 |
* The date and time at which the object was deleted. |
| 274 |
* |
| 275 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-deleted |
| 276 |
* |
| 277 |
* @var string|null |
| 278 |
*/ |
| 279 |
protected $deleted; |
| 280 |
|
| 281 |
/** |
| 282 |
* The former type of the object. Used in Tombstone objects to |
| 283 |
* indicate the type of the object prior to deletion. |
| 284 |
* |
| 285 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-formertype |
| 286 |
* |
| 287 |
* @var string|null |
| 288 |
*/ |
| 289 |
protected $former_type; |
| 290 |
|
| 291 |
/** |
| 292 |
* A simple, human-readable, plain-text name for the object. |
| 293 |
* HTML markup MUST NOT be included. |
| 294 |
* |
| 295 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-name |
| 296 |
* |
| 297 |
* @var string|null xsd:string |
| 298 |
*/ |
| 299 |
protected $name; |
| 300 |
|
| 301 |
/** |
| 302 |
* The name MAY be expressed using multiple language-tagged values. |
| 303 |
* |
| 304 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-name |
| 305 |
* |
| 306 |
* @var array|null rdf:langString |
| 307 |
*/ |
| 308 |
protected $name_map; |
| 309 |
|
| 310 |
/** |
| 311 |
* The date and time describing the actual or expected ending time |
| 312 |
* of the object. |
| 313 |
* When used with an Activity object, for instance, the endTime |
| 314 |
* property specifies the moment the activity concluded or |
| 315 |
* is expected to conclude. |
| 316 |
* |
| 317 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-endtime |
| 318 |
* |
| 319 |
* @var string|null |
| 320 |
*/ |
| 321 |
protected $end_time; |
| 322 |
|
| 323 |
/** |
| 324 |
* The entity (e.g. an application) that generated the object. |
| 325 |
* |
| 326 |
* @var string|null |
| 327 |
*/ |
| 328 |
protected $generator; |
| 329 |
|
| 330 |
/** |
| 331 |
* An entity that describes an icon for this object. |
| 332 |
* The image should have an aspect ratio of one (horizontal) |
| 333 |
* to one (vertical) and should be suitable for presentation |
| 334 |
* at a small size. |
| 335 |
* |
| 336 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-icon |
| 337 |
* |
| 338 |
* @var string|array|null |
| 339 |
*/ |
| 340 |
protected $icon; |
| 341 |
|
| 342 |
/** |
| 343 |
* An entity that describes an image for this object. |
| 344 |
* Unlike the icon property, there are no aspect ratio |
| 345 |
* or display size limitations assumed. |
| 346 |
* |
| 347 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-image-term |
| 348 |
* |
| 349 |
* @var string|array|null |
| 350 |
*/ |
| 351 |
protected $image; |
| 352 |
|
| 353 |
/** |
| 354 |
* One or more entities for which this object is considered a |
| 355 |
* response. |
| 356 |
* |
| 357 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-inreplyto |
| 358 |
* |
| 359 |
* @var string|null |
| 360 |
*/ |
| 361 |
protected $in_reply_to; |
| 362 |
|
| 363 |
/** |
| 364 |
* One or more physical or logical locations associated with the |
| 365 |
* object. |
| 366 |
* |
| 367 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-location |
| 368 |
* |
| 369 |
* @var string|null|Place |
| 370 |
*/ |
| 371 |
protected $location; |
| 372 |
|
| 373 |
/** |
| 374 |
* An entity that provides a preview of this object. |
| 375 |
* |
| 376 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-preview |
| 377 |
* |
| 378 |
* @var string|null |
| 379 |
*/ |
| 380 |
protected $preview; |
| 381 |
|
| 382 |
/** |
| 383 |
* The date and time at which the object was published |
| 384 |
* |
| 385 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-published |
| 386 |
* |
| 387 |
* @var string|null xsd:dateTime |
| 388 |
*/ |
| 389 |
protected $published; |
| 390 |
|
| 391 |
/** |
| 392 |
* The date and time describing the actual or expected starting time |
| 393 |
* of the object. |
| 394 |
* When used with an Activity object, for instance, the startTime |
| 395 |
* property specifies the moment the activity began |
| 396 |
* or is scheduled to begin. |
| 397 |
* |
| 398 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-starttime |
| 399 |
* |
| 400 |
* @var string|null xsd:dateTime |
| 401 |
*/ |
| 402 |
protected $start_time; |
| 403 |
|
| 404 |
/** |
| 405 |
* A natural language summarization of the object encoded as HTML. |
| 406 |
* Multiple language tagged summaries MAY be provided. |
| 407 |
* |
| 408 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary |
| 409 |
* |
| 410 |
* @var string|null |
| 411 |
*/ |
| 412 |
protected $summary; |
| 413 |
|
| 414 |
/** |
| 415 |
* The content MAY be expressed using multiple language-tagged |
| 416 |
* values. |
| 417 |
* |
| 418 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary |
| 419 |
* |
| 420 |
* @var string[]|null |
| 421 |
*/ |
| 422 |
protected $summary_map; |
| 423 |
|
| 424 |
/** |
| 425 |
* One or more "tags" that have been associated with an objects. |
| 426 |
* A tag can be any kind of Object. |
| 427 |
* The key difference between attachment and tag is that the former |
| 428 |
* implies association by inclusion, while the latter implies |
| 429 |
* associated by reference. |
| 430 |
* |
| 431 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tag |
| 432 |
* |
| 433 |
* @var string|null |
| 434 |
*/ |
| 435 |
protected $tag; |
| 436 |
|
| 437 |
/** |
| 438 |
* The date and time at which the object was updated |
| 439 |
* |
| 440 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-updated |
| 441 |
* |
| 442 |
* @var string|null xsd:dateTime |
| 443 |
*/ |
| 444 |
protected $updated; |
| 445 |
|
| 446 |
/** |
| 447 |
* One or more links to representations of the object. |
| 448 |
* |
| 449 |
* @var string|null |
| 450 |
*/ |
| 451 |
protected $url; |
| 452 |
|
| 453 |
/** |
| 454 |
* An entity considered to be part of the public primary audience |
| 455 |
* of an Object |
| 456 |
* |
| 457 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-to |
| 458 |
* |
| 459 |
* @var string|array|null |
| 460 |
*/ |
| 461 |
protected $to; |
| 462 |
|
| 463 |
/** |
| 464 |
* An Object that is part of the private primary audience of this |
| 465 |
* Object. |
| 466 |
* |
| 467 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-bto |
| 468 |
* |
| 469 |
* @var string|array|null |
| 470 |
*/ |
| 471 |
protected $bto; |
| 472 |
|
| 473 |
/** |
| 474 |
* An Object that is part of the public secondary audience of this |
| 475 |
* Object. |
| 476 |
* |
| 477 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-cc |
| 478 |
* |
| 479 |
* @var string|array|null |
| 480 |
*/ |
| 481 |
protected $cc; |
| 482 |
|
| 483 |
/** |
| 484 |
* One or more Objects that are part of the private secondary |
| 485 |
* audience of this Object. |
| 486 |
* |
| 487 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-bcc |
| 488 |
* |
| 489 |
* @var string|array|null |
| 490 |
*/ |
| 491 |
protected $bcc; |
| 492 |
|
| 493 |
/** |
| 494 |
* The MIME media type of the value of the content property. |
| 495 |
* If not specified, the content property is assumed to contain |
| 496 |
* text/html content. |
| 497 |
* |
| 498 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-mediatype |
| 499 |
* |
| 500 |
* @var string|null |
| 501 |
*/ |
| 502 |
protected $media_type; |
| 503 |
|
| 504 |
/** |
| 505 |
* When the object describes a time-bound resource, such as an audio |
| 506 |
* or video, a meeting, etc., the duration property indicates the |
| 507 |
* object's approximate duration. |
| 508 |
* The value MUST be expressed as a xsd:duration as defined by |
| 509 |
* xmlschema11-2, section 3.3.6 (e.g. a period of 5 seconds is |
| 510 |
* represented as "PT5S"). |
| 511 |
* |
| 512 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration |
| 513 |
* |
| 514 |
* @var string|null |
| 515 |
*/ |
| 516 |
protected $duration; |
| 517 |
|
| 518 |
/** |
| 519 |
* Intended to convey some sort of source from which the content |
| 520 |
* markup was derived, as a form of provenance, or to support |
| 521 |
* future editing by clients. |
| 522 |
* |
| 523 |
* @see https://www.w3.org/TR/activitypub/#source-property |
| 524 |
* |
| 525 |
* @var array|null |
| 526 |
*/ |
| 527 |
protected $source; |
| 528 |
|
| 529 |
/** |
| 530 |
* A Collection containing objects considered to be responses to |
| 531 |
* this object. |
| 532 |
* |
| 533 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-replies |
| 534 |
* |
| 535 |
* @var string|array|null |
| 536 |
*/ |
| 537 |
protected $replies; |
| 538 |
|
| 539 |
/** |
| 540 |
* A Collection containing objects considered to be likes for |
| 541 |
* this object. |
| 542 |
* |
| 543 |
* @see https://www.w3.org/TR/activitypub/#likes |
| 544 |
* |
| 545 |
* @var array|null |
| 546 |
*/ |
| 547 |
protected $likes; |
| 548 |
|
| 549 |
/** |
| 550 |
* A Collection containing objects considered to be shares for |
| 551 |
* this object. |
| 552 |
* |
| 553 |
* @see https://www.w3.org/TR/activitypub/#shares |
| 554 |
* |
| 555 |
* @var array|null |
| 556 |
*/ |
| 557 |
protected $shares; |
| 558 |
|
| 559 |
/** |
| 560 |
* Used to mark an object as containing sensitive content. |
| 561 |
* Mastodon displays a content warning, requiring users to click |
| 562 |
* through to view the content. |
| 563 |
* |
| 564 |
* @see https://docs.joinmastodon.org/spec/activitypub/#sensitive |
| 565 |
* |
| 566 |
* @var boolean|null |
| 567 |
*/ |
| 568 |
protected $sensitive; |
| 569 |
|
| 570 |
/** |
| 571 |
* The dcterms namespace. |
| 572 |
* |
| 573 |
* @see https://codeberg.org/fediverse/fep/src/branch/main/fep/b2b8/fep-b2b8.md#sensitive |
| 574 |
* @see https://www.dublincore.org/specifications/dublin-core/dcmi-terms/ |
| 575 |
* |
| 576 |
* @var array|null |
| 577 |
*/ |
| 578 |
protected $dcterms; |
| 579 |
|
| 580 |
/** |
| 581 |
* Interaction policy is an attempt to limit the harmful effects of unwanted replies and |
| 582 |
* other interactions on a user's posts (e.g., "reply guys"). |
| 583 |
* |
| 584 |
* It is also used by Mastodon to limit the ability to quote posts. |
| 585 |
* |
| 586 |
* @see https://docs.gotosocial.org/en/latest/federation/interaction_policy/ |
| 587 |
* @see https://blog.joinmastodon.org/2025/09/introducing-quote-posts/ |
| 588 |
* |
| 589 |
* @var array|null |
| 590 |
*/ |
| 591 |
protected $interaction_policy; |
| 592 |
|
| 593 |
/** |
| 594 |
* Fediverse Enhancement Proposal 044f: Quote Property |
| 595 |
* |
| 596 |
* @see https://codeberg.org/fediverse/fep/src/branch/main/fep/044f/fep-044f.md |
| 597 |
* @see https://w3id.org/fep/044f#quote |
| 598 |
* |
| 599 |
* @var string|null |
| 600 |
*/ |
| 601 |
protected $quote; |
| 602 |
|
| 603 |
/** |
| 604 |
* ActivityStreams quoteUrl property. |
| 605 |
* |
| 606 |
* @see https://www.w3.org/ns/activitystreams#quoteUrl |
| 607 |
* |
| 608 |
* @var string|null |
| 609 |
*/ |
| 610 |
protected $quote_url; |
| 611 |
|
| 612 |
/** |
| 613 |
* Fedibird-specific quoteUri property. |
| 614 |
* |
| 615 |
* @see https://fedibird.com/ns#quoteUri |
| 616 |
* |
| 617 |
* @var string|null |
| 618 |
*/ |
| 619 |
protected $quote_uri; |
| 620 |
|
| 621 |
/** |
| 622 |
* Misskey-specific quote property. |
| 623 |
* |
| 624 |
* @see https://misskey-hub.net/ns/#_misskey_quote |
| 625 |
* |
| 626 |
* @var string|null |
| 627 |
*/ |
| 628 |
protected $_misskey_quote; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore |
| 629 |
|
| 630 |
/** |
| 631 |
* Generic getter. |
| 632 |
* |
| 633 |
* @param string $key The key to get. |
| 634 |
* |
| 635 |
* @return mixed The value. |
| 636 |
*/ |
| 637 |
public function get( $key ) { |
| 638 |
if ( ! $this->has( $key ) ) { |
| 639 |
return new \WP_Error( 'invalid_key', \__( 'Invalid key', 'activitypub' ), array( 'status' => 404 ) ); |
| 640 |
} |
| 641 |
|
| 642 |
return parent::get( $key ); |
| 643 |
} |
| 644 |
|
| 645 |
/** |
| 646 |
* Generic setter. |
| 647 |
* |
| 648 |
* @param string $key The key to set. |
| 649 |
* @param string $value The value to set. |
| 650 |
* |
| 651 |
* @return mixed The value. |
| 652 |
*/ |
| 653 |
public function set( $key, $value ) { |
| 654 |
if ( ! $this->has( $key ) ) { |
| 655 |
return new \WP_Error( 'invalid_key', \__( 'Invalid key', 'activitypub' ), array( 'status' => 404 ) ); |
| 656 |
} |
| 657 |
|
| 658 |
return parent::set( $key, $value ); |
| 659 |
} |
| 660 |
|
| 661 |
/** |
| 662 |
* Generic adder. |
| 663 |
* |
| 664 |
* @param string $key The key to set. |
| 665 |
* @param mixed $value The value to add. |
| 666 |
* |
| 667 |
* @return mixed The value. |
| 668 |
*/ |
| 669 |
public function add( $key, $value ) { |
| 670 |
if ( ! $this->has( $key ) ) { |
| 671 |
return new \WP_Error( 'invalid_key', \__( 'Invalid key', 'activitypub' ), array( 'status' => 404 ) ); |
| 672 |
} |
| 673 |
|
| 674 |
return parent::add( $key, $value ); |
| 675 |
} |
| 676 |
} |
| 677 |
|