PluginProbe
ActivityPub / 5.1.0
ActivityPub v5.1.0
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/handler/class-update.php +44 -26 2.0.05.1.0 View file →
@@ -1,8 +1,13 @@
1 1 <?php
2 +/**
3 + * Update handler file.
4 + *
5 + * @package Activitypub
6 + */
7 +
2 8 namespace Activitypub\Handler;
3 9
4 -use WP_Error;
5 10 use Activitypub\Collection\Interactions;
6 11
7 12 use function Activitypub\get_remote_metadata_by_actor;
8 13
@@ -10,9 +15,9 @@
10 15 * Handle Update requests.
11 16 */
12 17 class Update {
13 18 /**
14 - * Initialize the class, registering WordPress hooks
19 + * Initialize the class, registering WordPress hooks.
15 20 */
16 21 public static function init() {
17 22 \add_action(
18 23 'activitypub_inbox_update',
@@ -20,28 +25,34 @@
20 25 );
21 26 }
22 27
23 28 /**
24 - * Handle "Update" requests
29 + * Handle "Update" requests.
25 30 *
26 - * @param array $array The activity-object
27 - * @param int $user_id The id of the local blog-user
31 + * @param array $activity The Activity object.
28 32 */
29 - public static function handle_update( $array ) {
30 - $object_type = isset( $array['object']['type'] ) ? $array['object']['type'] : '';
33 + public static function handle_update( $activity ) {
34 + $object_type = isset( $activity['object']['type'] ) ? $activity['object']['type'] : '';
31 35
32 36 switch ( $object_type ) {
33 - // Actor Types
34 - // @see https://www.w3.org/TR/activitystreams-vocabulary/#actor-types
37 + /*
38 + * Actor Types.
39 + *
40 + * @see https://www.w3.org/TR/activitystreams-vocabulary/#actor-types
41 + */
35 42 case 'Person':
36 43 case 'Group':
37 44 case 'Organization':
38 45 case 'Service':
39 46 case 'Application':
40 - self::update_actor( $array );
47 + self::update_actor( $activity );
41 48 break;
42 - // Object and Link Types
43 - // @see https://www.w3.org/TR/activitystreams-vocabulary/#object-types
49 +
50 + /*
51 + * Object and Link Types.
52 + *
53 + * @see https://www.w3.org/TR/activitystreams-vocabulary/#object-types
54 + */
44 55 case 'Note':
45 56 case 'Article':
46 57 case 'Image':
47 58 case 'Audio':
@@ -47,12 +58,16 @@
47 58 case 'Audio':
48 59 case 'Video':
49 60 case 'Event':
50 61 case 'Document':
51 - self::update_interaction( $array );
62 + self::update_interaction( $activity );
52 63 break;
53 - // Minimal Activity
54 - // @see https://www.w3.org/TR/activitystreams-core/#example-1
64 +
65 + /*
66 + * Minimal Activity.
67 + *
68 + * @see https://www.w3.org/TR/activitystreams-core/#example-1
69 + */
55 70 default:
56 71 break;
57 72 }
58 73 }
@@ -57,14 +72,11 @@
57 72 }
58 73 }
59 74
60 75 /**
61 - * Update an Interaction
76 + * Update an Interaction.
62 77 *
63 - * @param array $activity The activity-object
64 - * @param int $user_id The id of the local blog-user
65 - *
66 - * @return void
78 + * @param array $activity The Activity object.
67 79 */
68 80 public static function update_interaction( $activity ) {
69 81 $commentdata = Interactions::update_comment( $activity );
70 82 $reaction = null;
@@ -75,21 +87,27 @@
75 87 } else {
76 88 $state = $commentdata;
77 89 }
78 90
91 + /**
92 + * Fires after an Update activity has been handled.
93 + *
94 + * @param array $activity The complete Update activity data.
95 + * @param null $user Always null for Update activities.
96 + * @param int|array $state 1 if comment was updated successfully, error data otherwise.
97 + * @param \WP_Comment|null $reaction The updated comment object if successful, null otherwise.
98 + */
79 99 \do_action( 'activitypub_handled_update', $activity, null, $state, $reaction );
80 100 }
81 101
82 102 /**
83 - * Update an Actor
103 + * Update an Actor.
84 104 *
85 - * @param array $activity The activity-object
86 - *
87 - * @return void
105 + * @param array $activity The Activity object.
88 106 */
89 107 public static function update_actor( $activity ) {
90 - // update cache
108 + // Update cache.
91 109 get_remote_metadata_by_actor( $activity['actor'], false );
92 110
93 - // @todo maybe also update all interactions
111 + // @todo maybe also update all interactions.
94 112 }
95 113 }