PluginProbe
ActivityPub / 5.7.0
ActivityPub v5.7.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/class-dispatcher.php +114 -226 9.2.05.7.0 View file →
@@ -18,98 +18,67 @@
18 18 *
19 19 * @see https://www.w3.org/TR/activitypub/
20 20 */
21 21 class Dispatcher {
22 +
22 23 /**
23 24 * Batch size.
24 25 *
25 - * @deprecated 7.6.0 Use {@see Dispatcher::get_batch_size()}.
26 - *
27 26 * @var int
28 27 */
29 28 public static $batch_size = ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE;
30 29
31 30 /**
31 + * Callback for the async batch processing.
32 + *
33 + * @var array
34 + */
35 + public static $callback = array( self::class, 'send_to_followers' );
36 +
37 + /**
38 + * Error codes that qualify for a retry.
39 + *
40 + * @see https://github.com/tfredrich/RestApiTutorial.com/blob/fd08b0f67f07450521d143b123cd6e1846cb2e3b/content/advanced/responses/retries.md
41 + * @var int[]
42 + */
43 + public static $retry_error_codes = array( 408, 429, 500, 502, 503, 504 );
44 +
45 + /**
32 46 * Initialize the class, registering WordPress hooks.
33 47 */
34 48 public static function init() {
35 49 \add_action( 'activitypub_process_outbox', array( self::class, 'process_outbox' ) );
36 50
37 - \add_action( 'post_activitypub_add_to_outbox', array( self::class, 'fire_outbox_handlers' ), 5, 2 );
38 - \add_action( 'post_activitypub_add_to_outbox', array( self::class, 'send_immediate_accept' ), 10, 2 );
39 -
40 51 // Default filters to add Inboxes to sent to.
41 52 \add_filter( 'activitypub_additional_inboxes', array( self::class, 'add_inboxes_by_mentioned_actors' ), 10, 3 );
42 53 \add_filter( 'activitypub_additional_inboxes', array( self::class, 'add_inboxes_of_replied_urls' ), 10, 3 );
43 54 \add_filter( 'activitypub_additional_inboxes', array( self::class, 'add_inboxes_of_relays' ), 10, 3 );
44 55
45 - Scheduler::register_async_batch_callback( 'activitypub_send_activity', array( self::class, 'send_to_followers' ) );
46 - Scheduler::register_async_batch_callback( 'activitypub_retry_activity', array( self::class, 'retry_send_to_followers' ) );
47 - }
56 + // Fallback for `activitypub_send_to_inboxes` filter.
57 + \add_filter(
58 + 'activitypub_additional_inboxes',
59 + function ( $inboxes, $actor_id, $activity ) {
60 + /**
61 + * Filters the list of interactees inboxes to send the Activity to.
62 + *
63 + * @param array $inboxes The list of inboxes to send to.
64 + * @param int $actor_id The actor ID.
65 + * @param Activity $activity The ActivityPub Activity.
66 + *
67 + * @deprecated 5.2.0 Use `activitypub_additional_inboxes` instead.
68 + * @deprecated 5.4.0 Use `activitypub_additional_inboxes` instead.
69 + */
70 + $inboxes = \apply_filters_deprecated( 'activitypub_send_to_inboxes', array( $inboxes, $actor_id, $activity ), '5.2.0', 'activitypub_additional_inboxes' );
71 + $inboxes = \apply_filters_deprecated( 'activitypub_interactees_inboxes', array( $inboxes, $actor_id, $activity ), '5.4.0', 'activitypub_additional_inboxes' );
48 72
49 - /**
50 - * Get the batch size for processing outbox items.
51 - *
52 - * @return int The batch size.
53 - */
54 - public static function get_batch_size() {
55 - /**
56 - * Filters the batch size for processing outbox items.
57 - *
58 - * @param int $batch_size The batch size. Default ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE.
59 - */
60 - return \apply_filters( 'activitypub_dispatcher_batch_size', ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE );
73 + return $inboxes;
74 + },
75 + 10,
76 + 3
77 + );
61 78 }
62 79
63 80 /**
64 - * Get the maximum number of retry attempts.
65 - *
66 - * @return int The maximum number of retry attempts.
67 - */
68 - public static function get_retry_max_attempts() {
69 - /**
70 - * Filters the maximum number of retry attempts.
71 - *
72 - * @param int $retry_max_attempts The maximum number of retry attempts. Default ACTIVITYPUB_OUTBOX_RETRY_MAX_ATTEMPTS.
73 - */
74 - return \apply_filters( 'activitypub_dispatcher_retry_max_attempts', 3 );
75 - }
76 -
77 - /**
78 - * Get the retry delay unit (in seconds).
79 - *
80 - * Used to calculate exponential backoff: time() + (attempt * attempt * retry_delay_unit).
81 - *
82 - * @return int The retry delay unit in seconds.
83 - */
84 - public static function get_retry_delay() {
85 - /**
86 - * Filters the retry delay unit (in seconds).
87 - *
88 - * Used to calculate exponential backoff: time() + (attempt * attempt * retry_delay_unit).
89 - *
90 - * @param int $retry_delay_unit The retry delay unit in seconds. Default ACTIVITYPUB_OUTBOX_RETRY_DELAY_UNIT.
91 - */
92 - return \apply_filters( 'activitypub_dispatcher_retry_delay', HOUR_IN_SECONDS );
93 - }
94 -
95 - /**
96 - * Get the error codes that qualify for a retry.
97 - *
98 - * @see https://github.com/tfredrich/RestApiTutorial.com/blob/fd08b0f67f07450521d143b123cd6e1846cb2e3b/content/advanced/responses/retries.md
99 - *
100 - * @return int[] The error codes.
101 - */
102 - public static function get_retry_error_codes() {
103 - /**
104 - * Filters the error codes that qualify for a retry.
105 - *
106 - * @param int[] $retry_error_codes The error codes. Default array( 408, 429, 500, 502, 503, 504 ).
107 - */
108 - return \apply_filters( 'activitypub_dispatcher_retry_error_codes', ACTIVITYPUB_RETRY_ERROR_CODES );
109 - }
110 -
111 - /**
112 81 * Process the outbox.
113 82 *
114 83 * @param int $id The outbox ID.
115 84 */
@@ -120,11 +89,10 @@
120 89 if ( ! $outbox_item ) {
121 90 return;
122 91 }
123 92
124 - $type = \get_post_meta( $outbox_item->ID, '_activitypub_activity_type', true );
125 93 $actor = Outbox::get_actor( $outbox_item );
126 - if ( \is_wp_error( $actor ) && 'Delete' !== $type ) {
94 + if ( \is_wp_error( $actor ) ) {
127 95 // If the actor is not found, publish the post and don't try again.
128 96 \wp_publish_post( $outbox_item );
129 97 return;
130 98 }
@@ -131,15 +99,15 @@
131 99
132 100 $activity = Outbox::get_activity( $outbox_item );
133 101
134 102 // Send to mentioned and replied-to users. Everyone other than followers.
135 - self::send_to_additional_inboxes( $activity, $outbox_item->post_author, $outbox_item );
103 + self::send_to_additional_inboxes( $activity, $actor->get__id(), $outbox_item );
136 104
137 105 if ( self::should_send_to_followers( $activity, $actor, $outbox_item ) ) {
138 - \do_action(
139 - 'activitypub_send_activity',
106 + Scheduler::async_batch(
107 + self::$callback,
140 108 $outbox_item->ID,
141 - self::get_batch_size(),
109 + self::$batch_size,
142 110 \get_post_meta( $outbox_item->ID, '_activitypub_outbox_offset', true ) ?: 0 // phpcs:ignore
143 111 );
144 112 } else {
145 113 // No followers to process for this update. We're done.
@@ -150,33 +118,19 @@
150 118
151 119 /**
152 120 * Asynchronously runs batch processing routines.
153 121 *
154 - * @param int $outbox_item_id The Outbox item ID.
155 - * @param int|null $batch_size Optional. The batch size. Default null (uses filtered batch size).
156 - * @param int $offset Optional. The offset. Default 0.
122 + * @param int $outbox_item_id The Outbox item ID.
123 + * @param int $batch_size Optional. The batch size. Default ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE.
124 + * @param int $offset Optional. The offset. Default 0.
157 125 *
158 126 * @return array|void The next batch of followers to process, or void if done.
159 127 */
160 128 public static function send_to_followers( $outbox_item_id, $batch_size = ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE, $offset = 0 ) {
161 - if ( null === $batch_size ) {
162 - $batch_size = self::get_batch_size();
163 - }
129 + $json = Outbox::get_activity( $outbox_item_id )->to_json();
130 + $actor = Outbox::get_actor( \get_post( $outbox_item_id ) );
131 + $inboxes = Followers::get_inboxes_for_activity( $json, $actor->get__id(), $batch_size, $offset );
164 132
165 - $outbox_item = \get_post( $outbox_item_id );
166 -
167 - if ( ! $outbox_item ) {
168 - return;
169 - }
170 -
171 - $activity = Outbox::get_activity( $outbox_item_id );
172 -
173 - if ( \is_wp_error( $activity ) ) {
174 - return;
175 - }
176 -
177 - $json = $activity->to_json();
178 - $inboxes = Followers::get_inboxes_for_activity( $json, $outbox_item->post_author, $batch_size, $offset );
179 133 $retries = self::send_to_inboxes( $inboxes, $outbox_item_id );
180 134
181 135 // Retry failed inboxes.
182 136 if ( ! empty( $retries ) ) {
@@ -182,9 +136,9 @@
182 136 if ( ! empty( $retries ) ) {
183 137 self::schedule_retry( $retries, $outbox_item_id );
184 138 }
185 139
186 - if ( \is_countable( $inboxes ) && \count( $inboxes ) < $batch_size ) {
140 + if ( is_countable( $inboxes ) && count( $inboxes ) < $batch_size ) {
187 141 \delete_post_meta( $outbox_item_id, '_activitypub_outbox_offset' );
188 142
189 143 /**
190 144 * Fires when the followers are complete.
@@ -195,9 +149,9 @@
195 149 * @param int $outbox_item_id The Outbox item ID.
196 150 * @param int $batch_size The batch size.
197 151 * @param int $offset The offset.
198 152 */
199 - \do_action( 'activitypub_outbox_processing_complete', $inboxes, $json, $outbox_item->post_author, $outbox_item_id, $batch_size, $offset );
153 + \do_action( 'activitypub_outbox_processing_complete', $inboxes, $json, $actor->get__id(), $outbox_item_id, $batch_size, $offset );
200 154
201 155 // No more followers to process for this update.
202 156 \wp_publish_post( $outbox_item_id );
203 157 } else {
@@ -212,9 +166,9 @@
212 166 * @param int $outbox_item_id The Outbox item ID.
213 167 * @param int $batch_size The batch size.
214 168 * @param int $offset The offset.
215 169 */
216 - \do_action( 'activitypub_outbox_processing_batch_complete', $inboxes, $json, $outbox_item->post_author, $outbox_item_id, $batch_size, $offset );
170 + \do_action( 'activitypub_outbox_processing_batch_complete', $inboxes, $json, $actor->get__id(), $outbox_item_id, $batch_size, $offset );
217 171
218 172 return array( $outbox_item_id, $batch_size, $offset + $batch_size );
219 173 }
220 174 }
@@ -237,9 +191,9 @@
237 191
238 192 $retries = self::send_to_inboxes( $inboxes, $outbox_item_id );
239 193
240 194 // Retry failed inboxes.
241 - if ( ++$attempt < self::get_retry_max_attempts() && ! empty( $retries ) ) {
195 + if ( ++$attempt < 3 && ! empty( $retries ) ) {
242 196 self::schedule_retry( $retries, $outbox_item_id, $attempt );
243 197 }
244 198 }
245 199
@@ -250,18 +204,10 @@
250 204 * @param int $outbox_item_id The Outbox item ID.
251 205 * @return array The failed inboxes.
252 206 */
253 207 private static function send_to_inboxes( $inboxes, $outbox_item_id ) {
254 - $outbox_item = \get_post( $outbox_item_id );
255 -
256 - $activity = Outbox::get_activity( $outbox_item_id );
257 -
258 - if ( \is_wp_error( $activity ) ) {
259 - return array();
260 - }
261 -
262 - $json = $activity->to_json();
263 -
208 + $json = Outbox::get_activity( $outbox_item_id )->to_json();
209 + $actor = Outbox::get_actor( \get_post( $outbox_item_id ) );
264 210 $retries = array();
265 211
266 212 /**
267 213 * Fires before sending an Activity to inboxes.
@@ -272,16 +218,11 @@
272 218 */
273 219 \do_action( 'activitypub_pre_send_to_inboxes', $json, $inboxes, $outbox_item_id );
274 220
275 221 foreach ( $inboxes as $inbox ) {
276 - // Handle local inboxes via internal REST API, remote via HTTP.
277 - if ( is_same_domain( $inbox ) ) {
278 - $result = self::send_to_local_inbox( $inbox, $json );
279 - } else {
280 - $result = safe_remote_post( $inbox, $json, $outbox_item->post_author );
281 - }
222 + $result = safe_remote_post( $inbox, $json, $actor->get__id() );
282 223
283 - if ( \is_wp_error( $result ) && \in_array( $result->get_error_code(), self::get_retry_error_codes(), true ) ) {
224 + if ( is_wp_error( $result ) && in_array( $result->get_error_code(), self::$retry_error_codes, true ) ) {
284 225 $retries[] = $inbox;
285 226 }
286 227
287 228 /**
@@ -286,15 +227,15 @@
286 227
287 228 /**
288 229 * Fires after an Activity has been sent to an inbox.
289 230 *
290 - * @param array $result The result of the internal or remote post request.
231 + * @param array $result The result of the remote post request.
291 232 * @param string $inbox The inbox URL.
292 233 * @param string $json The ActivityPub Activity JSON.
293 234 * @param int $actor_id The actor ID.
294 235 * @param int $outbox_item_id The Outbox item ID.
295 236 */
296 - \do_action( 'activitypub_sent_to_inbox', $result, $inbox, $json, $outbox_item->post_author, $outbox_item_id );
237 + \do_action( 'activitypub_sent_to_inbox', $result, $inbox, $json, $actor->get__id(), $outbox_item_id );
297 238 }
298 239
299 240 return $retries;
300 241 }
@@ -299,43 +240,8 @@
299 240 return $retries;
300 241 }
301 242
302 243 /**
303 - * Send an activity to a local inbox via internal REST API request.
304 - *
305 - * @param string $inbox_url The local inbox URL.
306 - * @param string $json The ActivityPub Activity JSON.
307 - * @return array|\WP_Error The result in the format of a remote post response, or WP_Error on failure.
308 - */
309 - private static function send_to_local_inbox( $inbox_url, $json ) {
310 - // Parse the inbox URL to extract the REST route.
311 - $path = \wp_parse_url( $inbox_url, PHP_URL_PATH ) ?? '';
312 - $rest_route = \preg_replace( '#^/' . \preg_quote( \rest_get_url_prefix(), '#' ) . '#', '', $path );
313 -
314 - // Create a REST request.
315 - $request = new \WP_REST_Request( 'POST', $rest_route );
316 - $request->set_header( 'Content-Type', 'application/activity+json' );
317 - $request->set_body( $json );
318 - $request->get_json_params();
319 -
320 - \add_filter( 'activitypub_defer_signature_verification', '__return_true' );
321 - $response = \rest_do_request( $request );
322 - \remove_filter( 'activitypub_defer_signature_verification', '__return_true' );
323 -
324 - // Return result in format similar to remote post response.
325 - if ( $response->is_error() ) {
326 - return $response->as_error();
327 - }
328 -
329 - return array(
330 - 'response' => array(
331 - 'code' => $response->get_status(),
332 - ),
333 - 'body' => \wp_json_encode( $response->get_data() ),
334 - );
335 - }
336 -
337 - /**
338 244 * Schedule a retry.
339 245 *
340 246 * @param array $retries The inboxes to retry.
341 247 * @param int $outbox_item_id The Outbox item ID.
@@ -345,11 +251,16 @@
345 251 $transient_key = 'activitypub_retry_' . \wp_generate_password( 12, false );
346 252 \set_transient( $transient_key, $retries, WEEK_IN_SECONDS );
347 253
348 254 \wp_schedule_single_event(
349 - \time() + ( $attempt * $attempt * self::get_retry_delay() ),
350 - 'activitypub_retry_activity',
351 - array( $transient_key, $outbox_item_id, $attempt )
255 + \time() + ( $attempt * $attempt * HOUR_IN_SECONDS ),
256 + 'activitypub_async_batch',
257 + array(
258 + array( self::class, 'retry_send_to_followers' ),
259 + $transient_key,
260 + $outbox_item_id,
261 + $attempt,
262 + )
352 263 );
353 264 }
354 265
355 266 /**
@@ -368,10 +279,10 @@
368 279 * @param array $inboxes The list of inboxes to send to.
369 280 * @param int $actor_id The actor ID.
370 281 * @param Activity $activity The ActivityPub Activity.
371 282 */
372 - $inboxes = \apply_filters( 'activitypub_additional_inboxes', array(), $actor_id, $activity );
373 - $inboxes = \array_unique( $inboxes );
283 + $inboxes = apply_filters( 'activitypub_additional_inboxes', array(), $actor_id, $activity );
284 + $inboxes = array_unique( $inboxes );
374 285
375 286 $retries = self::send_to_inboxes( $inboxes, $outbox_item->ID );
376 287
377 288 // Retry failed inboxes.
@@ -392,17 +303,22 @@
392 303 public static function add_inboxes_by_mentioned_actors( $inboxes, $actor_id, $activity ) {
393 304 $cc = $activity->get_cc() ?? array();
394 305 $to = $activity->get_to() ?? array();
395 306
396 - $audience = \array_merge( $cc, $to );
307 + $audience = array_merge( $cc, $to );
397 308
398 - // Remove "public placeholder" from the audience.
399 - $audience = \array_diff( $audience, ACTIVITYPUB_PUBLIC_AUDIENCE_IDENTIFIERS );
309 + // Remove "public placeholder" and "same domain" from the audience.
310 + $audience = array_filter(
311 + $audience,
312 + function ( $actor ) {
313 + return 'https://www.w3.org/ns/activitystreams#Public' !== $actor && ! is_same_domain( $actor );
314 + }
315 + );
400 316
401 317 if ( $audience ) {
402 318 $mentioned_inboxes = Mention::get_inboxes( $audience );
403 319
404 - return \array_merge( $inboxes, $mentioned_inboxes );
320 + return array_merge( $inboxes, $mentioned_inboxes );
405 321 }
406 322
407 323 return $inboxes;
408 324 }
@@ -422,9 +338,9 @@
422 338 if ( ! $in_reply_to ) {
423 339 return $inboxes;
424 340 }
425 341
426 - if ( ! \is_array( $in_reply_to ) ) {
342 + if ( ! is_array( $in_reply_to ) ) {
427 343 $in_reply_to = array( $in_reply_to );
428 344 }
429 345
430 346 foreach ( $in_reply_to as $url ) {
@@ -460,36 +376,52 @@
460 376 return $inboxes;
461 377 }
462 378
463 379 /**
464 - * Check if an Activity should be sent to followers.
380 + * Adds Blog Actor inboxes to Updates so the Blog User's followers are notified of edits.
465 381 *
382 + * @deprecated 5.2.0 Use {@see Followers::maybe_add_inboxes_of_blog_user} instead.
383 + *
384 + * @param array $inboxes The list of Inboxes.
385 + * @param int $actor_id The WordPress Actor-ID.
386 + * @param Activity $activity The ActivityPub Activity.
387 + *
388 + * @return array The filtered Inboxes.
389 + */
390 + public static function maybe_add_inboxes_of_blog_user( $inboxes, $actor_id, $activity ) { // phpcs:ignore
391 + _deprecated_function( __METHOD__, '5.2.0', 'Followers::maybe_add_inboxes_of_blog_user' );
392 +
393 + return $inboxes;
394 + }
395 +
396 + /**
397 + * Check if passed Activity is public.
398 + *
466 399 * @param Activity $activity The Activity object.
467 400 * @param \Activitypub\Model\User|\Activitypub\Model\Blog $actor The Actor object.
468 401 * @param \WP_Post $outbox_item The Outbox item.
469 402 *
470 - * @return boolean True if the Activity should be sent to followers, false if not.
403 + * @return boolean True if public, false if not.
471 404 */
472 405 protected static function should_send_to_followers( $activity, $actor, $outbox_item ) {
473 - $cc = (array) ( $activity->get_cc() ?? array() );
474 - $to = (array) ( $activity->get_to() ?? array() );
475 - $bcc = (array) ( $activity->get_bcc() ?? array() );
476 - $bto = (array) ( $activity->get_bto() ?? array() );
406 + // Check if follower endpoint is set.
407 + $cc = $activity->get_cc() ?? array();
408 + $to = $activity->get_to() ?? array();
477 409
478 - $audience = \array_merge( $cc, $to, $bcc, $bto );
410 + $audience = array_merge( $cc, $to );
479 411
480 412 $send = (
481 413 // Check if activity is public.
482 - is_activity_public( $activity ) ||
414 + in_array( 'https://www.w3.org/ns/activitystreams#Public', $audience, true ) ||
483 415 // ...or check if follower endpoint is set.
484 - \in_array( $actor->get_followers(), $audience, true )
416 + in_array( $actor->get_followers(), $audience, true )
485 417 );
486 418
487 419 if ( $send ) {
488 - $followers = Followers::get_inboxes_for_activity( $activity->to_json(), $outbox_item->post_author );
420 + $followers = Followers::get_inboxes_for_activity( $activity->to_json(), $actor->get__id() );
489 421
490 422 // Only send if there are followers to send to.
491 - $send = ! \is_countable( $followers ) || 0 < \count( $followers );
423 + $send = ! is_countable( $followers ) || 0 < count( $followers );
492 424 }
493 425
494 426 /**
495 427 * Filters whether to send an Activity to followers.
@@ -498,9 +430,9 @@
498 430 * @param Activity $activity The ActivityPub Activity.
499 431 * @param int $actor_id The actor ID.
500 432 * @param \WP_Post $outbox_item The WordPress object.
501 433 */
502 - return \apply_filters( 'activitypub_send_activity_to_followers', $send, $activity, $outbox_item->post_author, $outbox_item );
434 + return apply_filters( 'activitypub_send_activity_to_followers', $send, $activity, $actor->get__id(), $outbox_item );
503 435 }
504 436
505 437 /**
506 438 * Add Inboxes of Relays.
@@ -511,10 +443,16 @@
511 443 *
512 444 * @return array The filtered Inboxes.
513 445 */
514 446 public static function add_inboxes_of_relays( $inboxes, $actor_id, $activity ) {
447 + // Check if follower endpoint is set.
448 + $cc = $activity->get_cc() ?? array();
449 + $to = $activity->get_to() ?? array();
450 +
451 + $audience = array_merge( $cc, $to );
452 +
515 453 // Check if activity is public.
516 - if ( ! is_activity_public( $activity ) ) {
454 + if ( ! in_array( 'https://www.w3.org/ns/activitystreams#Public', $audience, true ) ) {
517 455 return $inboxes;
518 456 }
519 457
520 458 $relays = \get_option( 'activitypub_relays', array() );
@@ -522,57 +460,7 @@
522 460 if ( empty( $relays ) ) {
523 461 return $inboxes;
524 462 }
525 463
526 - return \array_merge( $inboxes, $relays );
527 - }
528 -
529 - /**
530 - * Fire outbox handlers for activities.
531 - *
532 - * Triggers activity type-specific handlers to process outbox activities,
533 - * allowing handlers to create WordPress posts or perform other side effects.
534 - *
535 - * @param int $outbox_id The Outbox item ID.
536 - * @param Activity $activity The Activity that was just added to the Outbox.
537 - */
538 - public static function fire_outbox_handlers( $outbox_id, $activity ) {
539 - $outbox_item = \get_post( $outbox_id );
540 -
541 - if ( ! $outbox_item ) {
542 - return;
543 - }
544 -
545 - $type = $activity->get_type();
546 - $user_id = $outbox_item->post_author;
547 - $data = $activity->to_array( false );
548 -
549 - /**
550 - * Fires when an activity has been added to the outbox.
551 - *
552 - * Handlers can implement side effects like creating WordPress posts.
553 - *
554 - * @param array $data The activity data array.
555 - * @param int $user_id The user ID.
556 - * @param Activity $activity The Activity object.
557 - * @param int $outbox_id The outbox post ID.
558 - */
559 - \do_action( 'activitypub_handled_outbox_' . \strtolower( $type ), $data, $user_id, $activity, $outbox_id );
560 - }
561 -
562 - /**
563 - * Send an immediate Accept activity for the given Outbox item.
564 - *
565 - * @param int $outbox_id The Outbox item ID.
566 - * @param Activity $activity The Activity that was just added to the Outbox.
567 - */
568 - public static function send_immediate_accept( $outbox_id, $activity ) {
569 - $outbox_item = \get_post( $outbox_id );
570 -
571 - if ( ! $outbox_item || 'Accept' !== $activity->get_type() ) {
572 - return;
573 - }
574 -
575 - // Send to mentioned and replied-to users. Everyone other than followers.
576 - self::send_to_additional_inboxes( $activity, $outbox_item->post_author, $outbox_item );
464 + return array_merge( $inboxes, $relays );
577 465 }
578 466 }