PluginProbe
ActivityPub / 3.2.5
ActivityPub v3.2.5
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/activity/class-activity.php +30 -63 2.0.03.2.5 View file →
@@ -16,78 +16,18 @@
16 16 * @see https://www.w3.org/TR/activitystreams-core/#activities
17 17 * @see https://www.w3.org/TR/activitystreams-core/#intransitiveactivities
18 18 */
19 19 class Activity extends Base_Object {
20 - const CONTEXT = array(
20 + const JSON_LD_CONTEXT = array(
21 21 'https://www.w3.org/ns/activitystreams',
22 - 'https://w3id.org/security/v1',
23 - 'https://purl.archive.org/socialweb/webfinger',
24 - array(
25 - 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
26 - 'PropertyValue' => 'schema:PropertyValue',
27 - 'schema' => 'http://schema.org#',
28 - 'pt' => 'https://joinpeertube.org/ns#',
29 - 'toot' => 'http://joinmastodon.org/ns#',
30 - 'litepub' => 'http://litepub.social/ns#',
31 - 'lemmy' => 'https://join-lemmy.org/ns#',
32 - 'value' => 'schema:value',
33 - 'Hashtag' => 'as:Hashtag',
34 - 'featured' => array(
35 - '@id' => 'toot:featured',
36 - '@type' => '@id',
37 - ),
38 - 'featuredTags' => array(
39 - '@id' => 'toot:featuredTags',
40 - '@type' => '@id',
41 - ),
42 - 'alsoKnownAs' => array(
43 - '@id' => 'as:alsoKnownAs',
44 - '@type' => '@id',
45 - ),
46 - 'moderators' => array(
47 - '@id' => 'lemmy:moderators',
48 - '@type' => '@id',
49 - ),
50 - 'postingRestrictedToMods' => 'lemmy:postingRestrictedToMods',
51 - 'discoverable' => 'toot:discoverable',
52 - 'indexable' => 'toot:indexable',
53 - 'sensitive' => 'as:sensitive',
54 - ),
55 22 );
56 23
57 24 /**
58 - * The object's unique global identifier
59 - *
60 - * @see https://www.w3.org/TR/activitypub/#obj-id
61 - *
62 25 * @var string
63 26 */
64 - protected $id;
65 -
66 - /**
67 - * @var string
68 - */
69 27 protected $type = 'Activity';
70 28
71 29 /**
72 - * The context within which the object exists or an activity was
73 - * performed.
74 - * The notion of "context" used is intentionally vague.
75 - * The intended function is to serve as a means of grouping objects
76 - * and activities that share a common originating context or
77 - * purpose. An example could be all activities relating to a common
78 - * project or event.
79 - *
80 - * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-context
81 - *
82 - * @var string
83 - * | ObjectType
84 - * | Link
85 - * | null
86 - */
87 - protected $context = self::CONTEXT;
88 -
89 - /**
90 30 * Describes the direct object of the activity.
91 31 * For instance, in the activity "John added a movie to his
92 32 * wishlist", the object of the activity is the movie added.
93 33 *
@@ -93,9 +33,9 @@
93 33 *
94 34 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object-term
95 35 *
96 36 * @var string
97 - * | Base_Objectr
37 + * | Base_Object
98 38 * | Link
99 39 * | null
100 40 */
101 41 protected $object;
@@ -220,9 +160,36 @@
220 160 if ( $object->get_attributed_to() && ! $this->get_actor() ) {
221 161 $this->set( 'actor', $object->get_attributed_to() );
222 162 }
223 163
164 + if ( $object->get_in_reply_to() ) {
165 + $this->set( 'in_reply_to', $object->get_in_reply_to() );
166 + }
167 +
224 168 if ( $object->get_id() && ! $this->get_id() ) {
225 - $this->set( 'id', $object->get_id() . '#activity' );
169 + $id = strtok( $object->get_id(), '#' );
170 + if ( $object->get_updated() ) {
171 + $updated = $object->get_updated();
172 + } else {
173 + $updated = $object->get_published();
174 + }
175 + $this->set( 'id', $id . '#activity-' . strtolower( $this->get_type() ) . '-' . $updated );
226 176 }
177 + }
178 +
179 + /**
180 + * The context of an Activity is usually just the context of the object it contains.
181 + *
182 + * @return array $context A compacted JSON-LD context.
183 + */
184 + public function get_json_ld_context() {
185 + if ( $this->object instanceof Base_Object ) {
186 + $class = get_class( $this->object );
187 + if ( $class && $class::JSON_LD_CONTEXT ) {
188 + // Without php 5.6 support this could be just: 'return $this->object::JSON_LD_CONTEXT;'
189 + return $class::JSON_LD_CONTEXT;
190 + }
191 + }
192 +
193 + return static::JSON_LD_CONTEXT;
227 194 }
228 195 }