@@ -33,27 +33,25 @@ public static function init() {
3333 /**
3434 * Handles "Announce" requests.
3535 *
36- * @param array $array The activity-object.
37- * @param int $user_id The id of the local blog-user.
38- * @param \Activitypub\Activity\Activity $activity The activity object.
39- *
40- * @return void
36+ * @param array $announcement The activity-object.
37+ * @param int $user_id The id of the local blog-user.
38+ * @param \Activitypub\Activity\Activity $activity The activity object.
4139 */
42- public static function handle_announce ( $ array , $ user_id , $ activity = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound
40+ public static function handle_announce ( $ announcement , $ user_id , $ activity = null ) {
4341 // Check if Activity is public or not.
44- if ( ! is_activity_public ( $ array ) ) {
42+ if ( ! is_activity_public ( $ announcement ) ) {
4543 // @todo maybe send email
4644 return ;
4745 }
4846
4947 if ( ! ACTIVITYPUB_DISABLE_REACTIONS ) {
50- self ::maybe_save_announce ( $ array , $ user_id, $ activity );
48+ self ::maybe_save_announce ( $ announcement , $ user_id );
5149 }
5250
53- if ( is_string ( $ array ['object ' ] ) ) {
54- $ object = Http::get_remote_object ( $ array ['object ' ] );
51+ if ( is_string ( $ announcement ['object ' ] ) ) {
52+ $ object = Http::get_remote_object ( $ announcement ['object ' ] );
5553 } else {
56- $ object = $ array ['object ' ];
54+ $ object = $ announcement ['object ' ];
5755 }
5856
5957 if ( ! $ object || is_wp_error ( $ object ) ) {
@@ -66,21 +64,33 @@ public static function handle_announce( $array, $user_id, $activity = null ) { /
6664
6765 $ type = \strtolower ( $ object ['type ' ] );
6866
67+ /**
68+ * Fires after an Announce has been received.
69+ *
70+ * @param array $object The object.
71+ * @param int $user_id The id of the local blog-user.
72+ * @param array $activity The activity object.
73+ */
6974 \do_action ( 'activitypub_inbox ' , $ object , $ user_id , $ type , $ activity );
75+
76+ /**
77+ * Fires after an Announce of a specific type has been received.
78+ *
79+ * @param array $object The object.
80+ * @param int $user_id The id of the local blog-user.
81+ * @param array $activity The activity object.
82+ */
7083 \do_action ( "activitypub_inbox_ {$ type }" , $ object , $ user_id , $ activity );
7184 }
7285
7386 /**
7487 * Try to save the Announce.
7588 *
76- * @param array $array The activity-object.
77- * @param int $user_id The id of the local blog-user.
78- * @param \Activitypub\Activity\Activity $activity The activity object.
79- *
80- * @return void
89+ * @param array $activity The activity-object.
90+ * @param int $user_id The id of the local blog-user.
8191 */
82- public static function maybe_save_announce ( $ array , $ user_id, $ activity ) { // phpcs:ignore
83- $ url = object_to_uri ( $ array ['object ' ] );
92+ public static function maybe_save_announce ( $ activity , $ user_id ) {
93+ $ url = object_to_uri ( $ activity ['object ' ] );
8494
8595 if ( empty ( $ url ) ) {
8696 return ;
@@ -91,13 +101,21 @@ public static function maybe_save_announce( $array, $user_id, $activity ) { // p
91101 return ;
92102 }
93103
94- $ state = Interactions::add_reaction ( $ array );
104+ $ state = Interactions::add_reaction ( $ activity );
95105 $ reaction = null ;
96106
97107 if ( $ state && ! is_wp_error ( $ state ) ) {
98108 $ reaction = get_comment ( $ state );
99109 }
100110
101- do_action ( 'activitypub_handled_announce ' , $ array , $ user_id , $ state , $ reaction );
111+ /**
112+ * Fires after an Announce has been saved.
113+ *
114+ * @param array $activity The activity-object.
115+ * @param int $user_id The id of the local blog-user.
116+ * @param mixed $state The state of the reaction.
117+ * @param mixed $reaction The reaction.
118+ */
119+ do_action ( 'activitypub_handled_announce ' , $ activity , $ user_id , $ state , $ reaction );
102120 }
103121}
0 commit comments