updated plugin ActivityPub version 9.1.0
This commit is contained in:
@ -57,7 +57,7 @@ class Dispatcher {
|
||||
*
|
||||
* @param int $batch_size The batch size. Default ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE.
|
||||
*/
|
||||
return apply_filters( 'activitypub_dispatcher_batch_size', ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE );
|
||||
return \apply_filters( 'activitypub_dispatcher_batch_size', ACTIVITYPUB_OUTBOX_PROCESSING_BATCH_SIZE );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,7 +71,7 @@ class Dispatcher {
|
||||
*
|
||||
* @param int $retry_max_attempts The maximum number of retry attempts. Default ACTIVITYPUB_OUTBOX_RETRY_MAX_ATTEMPTS.
|
||||
*/
|
||||
return apply_filters( 'activitypub_dispatcher_retry_max_attempts', 3 );
|
||||
return \apply_filters( 'activitypub_dispatcher_retry_max_attempts', 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,7 +89,7 @@ class Dispatcher {
|
||||
*
|
||||
* @param int $retry_delay_unit The retry delay unit in seconds. Default ACTIVITYPUB_OUTBOX_RETRY_DELAY_UNIT.
|
||||
*/
|
||||
return apply_filters( 'activitypub_dispatcher_retry_delay', HOUR_IN_SECONDS );
|
||||
return \apply_filters( 'activitypub_dispatcher_retry_delay', HOUR_IN_SECONDS );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,7 +105,7 @@ class Dispatcher {
|
||||
*
|
||||
* @param int[] $retry_error_codes The error codes. Default array( 408, 429, 500, 502, 503, 504 ).
|
||||
*/
|
||||
return apply_filters( 'activitypub_dispatcher_retry_error_codes', ACTIVITYPUB_RETRY_ERROR_CODES );
|
||||
return \apply_filters( 'activitypub_dispatcher_retry_error_codes', ACTIVITYPUB_RETRY_ERROR_CODES );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,7 +183,7 @@ class Dispatcher {
|
||||
self::schedule_retry( $retries, $outbox_item_id );
|
||||
}
|
||||
|
||||
if ( is_countable( $inboxes ) && count( $inboxes ) < $batch_size ) {
|
||||
if ( \is_countable( $inboxes ) && \count( $inboxes ) < $batch_size ) {
|
||||
\delete_post_meta( $outbox_item_id, '_activitypub_outbox_offset' );
|
||||
|
||||
/**
|
||||
@ -280,7 +280,7 @@ class Dispatcher {
|
||||
$result = safe_remote_post( $inbox, $json, $outbox_item->post_author );
|
||||
}
|
||||
|
||||
if ( \is_wp_error( $result ) && in_array( $result->get_error_code(), self::get_retry_error_codes(), true ) ) {
|
||||
if ( \is_wp_error( $result ) && \in_array( $result->get_error_code(), self::get_retry_error_codes(), true ) ) {
|
||||
$retries[] = $inbox;
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ class Dispatcher {
|
||||
private static function send_to_local_inbox( $inbox_url, $json ) {
|
||||
// Parse the inbox URL to extract the REST route.
|
||||
$path = \wp_parse_url( $inbox_url, PHP_URL_PATH ) ?? '';
|
||||
$rest_route = \preg_replace( '#^/' . preg_quote( \rest_get_url_prefix(), '#' ) . '#', '', $path );
|
||||
$rest_route = \preg_replace( '#^/' . \preg_quote( \rest_get_url_prefix(), '#' ) . '#', '', $path );
|
||||
|
||||
// Create a REST request.
|
||||
$request = new \WP_REST_Request( 'POST', $rest_route );
|
||||
@ -369,8 +369,8 @@ class Dispatcher {
|
||||
* @param int $actor_id The actor ID.
|
||||
* @param Activity $activity The ActivityPub Activity.
|
||||
*/
|
||||
$inboxes = apply_filters( 'activitypub_additional_inboxes', array(), $actor_id, $activity );
|
||||
$inboxes = array_unique( $inboxes );
|
||||
$inboxes = \apply_filters( 'activitypub_additional_inboxes', array(), $actor_id, $activity );
|
||||
$inboxes = \array_unique( $inboxes );
|
||||
|
||||
$retries = self::send_to_inboxes( $inboxes, $outbox_item->ID );
|
||||
|
||||
@ -393,15 +393,15 @@ class Dispatcher {
|
||||
$cc = $activity->get_cc() ?? array();
|
||||
$to = $activity->get_to() ?? array();
|
||||
|
||||
$audience = array_merge( $cc, $to );
|
||||
$audience = \array_merge( $cc, $to );
|
||||
|
||||
// Remove "public placeholder" from the audience.
|
||||
$audience = array_diff( $audience, ACTIVITYPUB_PUBLIC_AUDIENCE_IDENTIFIERS );
|
||||
$audience = \array_diff( $audience, ACTIVITYPUB_PUBLIC_AUDIENCE_IDENTIFIERS );
|
||||
|
||||
if ( $audience ) {
|
||||
$mentioned_inboxes = Mention::get_inboxes( $audience );
|
||||
|
||||
return array_merge( $inboxes, $mentioned_inboxes );
|
||||
return \array_merge( $inboxes, $mentioned_inboxes );
|
||||
}
|
||||
|
||||
return $inboxes;
|
||||
@ -423,7 +423,7 @@ class Dispatcher {
|
||||
return $inboxes;
|
||||
}
|
||||
|
||||
if ( ! is_array( $in_reply_to ) ) {
|
||||
if ( ! \is_array( $in_reply_to ) ) {
|
||||
$in_reply_to = array( $in_reply_to );
|
||||
}
|
||||
|
||||
@ -475,20 +475,20 @@ class Dispatcher {
|
||||
$bcc = (array) ( $activity->get_bcc() ?? array() );
|
||||
$bto = (array) ( $activity->get_bto() ?? array() );
|
||||
|
||||
$audience = array_merge( $cc, $to, $bcc, $bto );
|
||||
$audience = \array_merge( $cc, $to, $bcc, $bto );
|
||||
|
||||
$send = (
|
||||
// Check if activity is public.
|
||||
is_activity_public( $activity ) ||
|
||||
// ...or check if follower endpoint is set.
|
||||
in_array( $actor->get_followers(), $audience, true )
|
||||
\in_array( $actor->get_followers(), $audience, true )
|
||||
);
|
||||
|
||||
if ( $send ) {
|
||||
$followers = Followers::get_inboxes_for_activity( $activity->to_json(), $outbox_item->post_author );
|
||||
|
||||
// Only send if there are followers to send to.
|
||||
$send = ! is_countable( $followers ) || 0 < count( $followers );
|
||||
$send = ! \is_countable( $followers ) || 0 < \count( $followers );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -499,7 +499,7 @@ class Dispatcher {
|
||||
* @param int $actor_id The actor ID.
|
||||
* @param \WP_Post $outbox_item The WordPress object.
|
||||
*/
|
||||
return apply_filters( 'activitypub_send_activity_to_followers', $send, $activity, $outbox_item->post_author, $outbox_item );
|
||||
return \apply_filters( 'activitypub_send_activity_to_followers', $send, $activity, $outbox_item->post_author, $outbox_item );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -523,7 +523,7 @@ class Dispatcher {
|
||||
return $inboxes;
|
||||
}
|
||||
|
||||
return array_merge( $inboxes, $relays );
|
||||
return \array_merge( $inboxes, $relays );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user