modified file wp-piwik

This commit is contained in:
2026-06-03 21:29:22 +00:00
committed by Gitium
parent 57bccfdbd1
commit 769efed689
2556 changed files with 368982 additions and 126264 deletions

View File

@ -0,0 +1,125 @@
<?php
/**
* Announce handler file.
*
* @package Activitypub
*/
namespace Activitypub\Handler;
use Activitypub\Http;
use Activitypub\Comment;
use Activitypub\Collection\Interactions;
use function Activitypub\object_to_uri;
use function Activitypub\is_activity_public;
/**
* Handle Create requests.
*/
class Announce {
/**
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
\add_action(
'activitypub_inbox_announce',
array( self::class, 'handle_announce' ),
10,
3
);
}
/**
* Handles "Announce" requests.
*
* @param array $announcement The activity-object.
* @param int $user_id The id of the local blog-user.
* @param \Activitypub\Activity\Activity $activity The activity object.
*/
public static function handle_announce( $announcement, $user_id, $activity = null ) {
// Check if Activity is public or not.
if ( ! is_activity_public( $announcement ) ) {
// @todo maybe send email
return;
}
// Check if reposts are allowed.
if ( ! Comment::is_comment_type_enabled( 'repost' ) ) {
return;
}
self::maybe_save_announce( $announcement, $user_id );
if ( is_string( $announcement['object'] ) ) {
$object = Http::get_remote_object( $announcement['object'] );
} else {
$object = $announcement['object'];
}
if ( ! $object || is_wp_error( $object ) ) {
return;
}
if ( ! isset( $object['type'] ) ) {
return;
}
$type = \strtolower( $object['type'] );
/**
* Fires after an Announce has been received.
*
* @param array $object The object.
* @param int $user_id The id of the local blog-user.
* @param string $type The type of the activity.
* @param \Activitypub\Activity\Activity|null $activity The activity object.
*/
\do_action( 'activitypub_inbox', $object, $user_id, $type, $activity );
/**
* Fires after an Announce of a specific type has been received.
*
* @param array $object The object.
* @param int $user_id The id of the local blog-user.
* @param \Activitypub\Activity\Activity|null $activity The activity object.
*/
\do_action( "activitypub_inbox_{$type}", $object, $user_id, $activity );
}
/**
* Try to save the Announce.
*
* @param array $activity The activity-object.
* @param int $user_id The id of the local blog-user.
*/
public static function maybe_save_announce( $activity, $user_id ) {
$url = object_to_uri( $activity['object'] );
if ( empty( $url ) ) {
return;
}
$exists = Comment::object_id_to_comment( esc_url_raw( $url ) );
if ( $exists ) {
return;
}
$state = Interactions::add_reaction( $activity );
$reaction = null;
if ( $state && ! is_wp_error( $state ) ) {
$reaction = get_comment( $state );
}
/**
* Fires after an Announce has been saved.
*
* @param array $activity The activity-object.
* @param int $user_id The id of the local blog-user.
* @param mixed $state The state of the reaction.
* @param mixed $reaction The reaction.
*/
do_action( 'activitypub_handled_announce', $activity, $user_id, $state, $reaction );
}
}

View File

@ -0,0 +1,133 @@
<?php
/**
* Create handler file.
*
* @package Activitypub
*/
namespace Activitypub\Handler;
use Activitypub\Collection\Interactions;
use function Activitypub\is_self_ping;
use function Activitypub\is_activity_reply;
use function Activitypub\is_activity_public;
use function Activitypub\object_id_to_comment;
/**
* Handle Create requests.
*/
class Create {
/**
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
\add_action(
'activitypub_inbox_create',
array( self::class, 'handle_create' ),
10,
3
);
\add_filter(
'activitypub_validate_object',
array( self::class, 'validate_object' ),
10,
3
);
}
/**
* Handles "Create" requests.
*
* @param array $activity The activity-object.
* @param int $user_id The id of the local blog-user.
* @param \Activitypub\Activity\Activity $activity_object Optional. The activity object. Default null.
*/
public static function handle_create( $activity, $user_id, $activity_object = null ) {
// Check if Activity is public or not.
if (
! is_activity_public( $activity ) ||
! is_activity_reply( $activity )
) {
return;
}
$check_dupe = object_id_to_comment( $activity['object']['id'] );
// If comment exists, call update action.
if ( $check_dupe ) {
/**
* Fires when a Create activity is received for an existing comment.
*
* @param array $activity The activity-object.
* @param int $user_id The id of the local blog-user.
* @param \Activitypub\Activity\Activity $activity_object The activity object.
*/
\do_action( 'activitypub_inbox_update', $activity, $user_id, $activity_object );
return;
}
if ( is_self_ping( $activity['object']['id'] ) ) {
return;
}
$state = Interactions::add_comment( $activity );
$reaction = null;
if ( $state && ! \is_wp_error( $state ) ) {
$reaction = \get_comment( $state );
}
/**
* Fires after a Create activity has been handled.
*
* @param array $activity The activity-object.
* @param int $user_id The id of the local blog-user.
* @param \WP_Comment|\WP_Error $state The comment object or WP_Error.
* @param \WP_Comment|\WP_Error|null $reaction The reaction object or WP_Error.
*/
\do_action( 'activitypub_handled_create', $activity, $user_id, $state, $reaction );
}
/**
* Validate the object.
*
* @param bool $valid The validation state.
* @param string $param The object parameter.
* @param \WP_REST_Request $request The request object.
*
* @return bool The validation state: true if valid, false if not.
*/
public static function validate_object( $valid, $param, $request ) {
$json_params = $request->get_json_params();
if ( empty( $json_params['type'] ) ) {
return false;
}
if (
'Create' !== $json_params['type'] ||
is_wp_error( $request )
) {
return $valid;
}
$object = $json_params['object'];
if ( ! is_array( $object ) ) {
return false;
}
$required = array(
'id',
'content',
);
if ( array_intersect( $required, array_keys( $object ) ) !== $required ) {
return false;
}
return $valid;
}
}

View File

@ -0,0 +1,196 @@
<?php
/**
* Delete handler file.
*
* @package Activitypub
*/
namespace Activitypub\Handler;
use WP_REST_Request;
use Activitypub\Http;
use Activitypub\Collection\Followers;
use Activitypub\Collection\Interactions;
use function Activitypub\object_to_uri;
/**
* Handles Delete requests.
*/
class Delete {
/**
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
\add_action( 'activitypub_inbox_delete', array( self::class, 'handle_delete' ) );
\add_filter( 'activitypub_defer_signature_verification', array( self::class, 'defer_signature_verification' ), 10, 2 );
\add_action( 'activitypub_delete_actor_interactions', array( self::class, 'delete_interactions' ) );
\add_filter( 'activitypub_get_outbox_activity', array( self::class, 'outbox_activity' ) );
}
/**
* Handles "Delete" requests.
*
* @param array $activity The delete activity.
*/
public static function handle_delete( $activity ) {
$object_type = isset( $activity['object']['type'] ) ? $activity['object']['type'] : '';
switch ( $object_type ) {
/*
* Actor Types.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#actor-types
*/
case 'Person':
case 'Group':
case 'Organization':
case 'Service':
case 'Application':
self::maybe_delete_follower( $activity );
break;
/*
* Object and Link Types.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#object-types
*/
case 'Note':
case 'Article':
case 'Image':
case 'Audio':
case 'Video':
case 'Event':
case 'Document':
self::maybe_delete_interaction( $activity );
break;
/*
* Tombstone Type.
*
* @see: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tombstone
*/
case 'Tombstone':
self::maybe_delete_interaction( $activity );
break;
/*
* Minimal Activity.
*
* @see https://www.w3.org/TR/activitystreams-core/#example-1
*/
default:
// Ignore non Minimal Activities.
if ( ! is_string( $activity['object'] ) ) {
return;
}
// Check if Object is an Actor.
if ( $activity['actor'] === $activity['object'] ) {
self::maybe_delete_follower( $activity );
} else { // Assume an interaction otherwise.
self::maybe_delete_interaction( $activity );
}
// Maybe handle Delete Activity for other Object Types.
break;
}
}
/**
* Delete a Follower if Actor-URL is a Tombstone.
*
* @param array $activity The delete activity.
*/
public static function maybe_delete_follower( $activity ) {
/* @var \Activitypub\Model\Follower $follower Follower object. */
$follower = Followers::get_follower_by_actor( $activity['actor'] );
// Verify that Actor is deleted.
if ( $follower && Http::is_tombstone( $activity['actor'] ) ) {
$follower->delete();
self::maybe_delete_interactions( $activity );
}
}
/**
* Delete Reactions if Actor-URL is a Tombstone.
*
* @param array $activity The delete activity.
*/
public static function maybe_delete_interactions( $activity ) {
// Verify that Actor is deleted.
if ( Http::is_tombstone( $activity['actor'] ) ) {
\wp_schedule_single_event(
\time(),
'activitypub_delete_actor_interactions',
array( $activity['actor'] )
);
}
}
/**
* Delete comments from an Actor.
*
* @param string $actor The URL of the actor whose comments to delete.
*/
public static function delete_interactions( $actor ) {
$comments = Interactions::get_interactions_by_actor( $actor );
foreach ( $comments as $comment ) {
wp_delete_comment( $comment, true );
}
}
/**
* Delete a Reaction if URL is a Tombstone.
*
* @param array $activity The delete activity.
*/
public static function maybe_delete_interaction( $activity ) {
if ( is_array( $activity['object'] ) ) {
$id = $activity['object']['id'];
} else {
$id = $activity['object'];
}
$comments = Interactions::get_interaction_by_id( $id );
if ( $comments && Http::is_tombstone( $id ) ) {
foreach ( $comments as $comment ) {
wp_delete_comment( $comment->comment_ID, true );
}
}
}
/**
* Defer signature verification for `Delete` requests.
*
* @param bool $defer Whether to defer signature verification.
* @param WP_REST_Request $request The request object.
*
* @return bool Whether to defer signature verification.
*/
public static function defer_signature_verification( $defer, $request ) {
$json = $request->get_json_params();
if ( isset( $json['type'] ) && 'Delete' === $json['type'] ) {
return true;
}
return false;
}
/**
* Set the object to the object ID.
*
* @param \Activitypub\Activity\Activity $activity The Activity object.
* @return \Activitypub\Activity\Activity The filtered Activity object.
*/
public static function outbox_activity( $activity ) {
if ( 'Delete' === $activity->get_type() ) {
$activity->set_object( object_to_uri( $activity->get_object() ) );
}
return $activity;
}
}

View File

@ -0,0 +1,114 @@
<?php
/**
* Follow handler file.
*
* @package Activitypub
*/
namespace Activitypub\Handler;
use Activitypub\Notification;
use Activitypub\Activity\Activity;
use Activitypub\Collection\Actors;
use Activitypub\Collection\Followers;
use function Activitypub\add_to_outbox;
/**
* Handle Follow requests.
*/
class Follow {
/**
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
\add_action(
'activitypub_inbox_follow',
array( self::class, 'handle_follow' )
);
\add_action(
'activitypub_followers_post_follow',
array( self::class, 'queue_accept' ),
10,
4
);
}
/**
* Handle "Follow" requests.
*
* @param array $activity The activity object.
*/
public static function handle_follow( $activity ) {
$user = Actors::get_by_resource( $activity['object'] );
if ( ! $user || is_wp_error( $user ) ) {
// If we can not find a user, we can not initiate a follow process.
return;
}
$user_id = $user->get__id();
// Save follower.
$follower = Followers::add_follower(
$user_id,
$activity['actor']
);
/**
* Fires after a new follower has been added.
*
* @param string $actor The URL of the actor (follower) who initiated the follow.
* @param array $activity The complete activity data of the follow request.
* @param int $user_id The ID of the WordPress user being followed.
* @param \Activitypub\Model\Follower|\WP_Error $follower The Follower object containing the new follower's data.
*/
do_action( 'activitypub_followers_post_follow', $activity['actor'], $activity, $user_id, $follower );
// Send notification.
$notification = new Notification(
'follow',
$activity['actor'],
$activity,
$user_id
);
$notification->send();
}
/**
* Send Accept response.
*
* @param string $actor The Actor URL.
* @param array $activity_object The Activity object.
* @param int $user_id The ID of the WordPress User.
* @param \Activitypub\Model\Follower|\WP_Error $follower The Follower object.
*/
public static function queue_accept( $actor, $activity_object, $user_id, $follower ) {
if ( \is_wp_error( $follower ) ) {
// Impossible to send a "Reject" because we can not get the Remote-Inbox.
return;
}
// Only send minimal data.
$activity_object = array_intersect_key(
$activity_object,
array_flip(
array(
'id',
'type',
'actor',
'object',
)
)
);
$activity = new Activity();
$activity->set_type( 'Accept' );
$activity->set_actor( Actors::get_by_id( $user_id )->get_id() );
$activity->set_object( $activity_object );
$activity->set_to( array( $actor ) );
add_to_outbox( $activity, null, $user_id, ACTIVITYPUB_CONTENT_VISIBILITY_PRIVATE );
}
}

View File

@ -0,0 +1,80 @@
<?php
/**
* Like handler file.
*
* @package Activitypub
*/
namespace Activitypub\Handler;
use Activitypub\Comment;
use Activitypub\Collection\Interactions;
use function Activitypub\object_to_uri;
/**
* Handle Like requests.
*/
class Like {
/**
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
\add_action( 'activitypub_inbox_like', array( self::class, 'handle_like' ), 10, 2 );
\add_filter( 'activitypub_get_outbox_activity', array( self::class, 'outbox_activity' ) );
}
/**
* Handles "Like" requests.
*
* @param array $like The Activity array.
* @param int $user_id The ID of the local blog user.
*/
public static function handle_like( $like, $user_id ) {
if ( ! Comment::is_comment_type_enabled( 'like' ) ) {
return;
}
$url = object_to_uri( $like['object'] );
if ( empty( $url ) ) {
return;
}
$exists = Comment::object_id_to_comment( esc_url_raw( $url ) );
if ( $exists ) {
return;
}
$state = Interactions::add_reaction( $like );
$reaction = null;
if ( $state && ! is_wp_error( $state ) ) {
$reaction = get_comment( $state );
}
/**
* Fires after a Like has been handled.
*
* @param array $like The Activity array.
* @param int $user_id The ID of the local blog user.
* @param mixed $state The state of the reaction.
* @param mixed $reaction The reaction object.
*/
do_action( 'activitypub_handled_like', $like, $user_id, $state, $reaction );
}
/**
* Set the object to the object ID.
*
* @param \Activitypub\Activity\Activity $activity The Activity object.
* @return \Activitypub\Activity\Activity The filtered Activity object.
*/
public static function outbox_activity( $activity ) {
if ( 'Like' === $activity->get_type() ) {
$activity->set_object( object_to_uri( $activity->get_object() ) );
}
return $activity;
}
}

View File

@ -0,0 +1,213 @@
<?php
/**
* Move handler file.
*
* @package Activitypub
*/
namespace Activitypub\Handler;
use Activitypub\Http;
use Activitypub\Collection\Followers;
use function Activitypub\object_to_uri;
/**
* Handle Move requests.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-move
* @see https://docs.joinmastodon.org/user/moving/
* @see https://docs.joinmastodon.org/spec/activitypub/#Move
*/
class Move {
/**
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
\add_action( 'activitypub_inbox_move', array( self::class, 'handle_move' ) );
\add_filter( 'activitypub_get_outbox_activity', array( self::class, 'outbox_activity' ) );
}
/**
* Handle Move requests.
*
* @param array $activity The JSON "Move" Activity.
*/
public static function handle_move( $activity ) {
$target = self::extract_target( $activity );
$origin = self::extract_origin( $activity );
if ( ! $target || ! $origin ) {
return;
}
$target_object = Http::get_remote_object( $target );
$origin_object = Http::get_remote_object( $origin );
$verified = self::verify_move( $target_object, $origin_object );
if ( ! $verified ) {
return;
}
$target_follower = Followers::get_follower_by_actor( $target );
$origin_follower = Followers::get_follower_by_actor( $origin );
/*
* If the new target is followed, but the origin is not,
* everything is fine, so we can return.
*/
if ( $target_follower && ! $origin_follower ) {
return;
}
/*
* If the new target is not followed, but the origin is,
* update the origin follower to the new target.
*/
if ( ! $target_follower && $origin_follower ) {
$origin_follower->from_array( $target_object );
$origin_follower->set_id( $target );
$origin_id = $origin_follower->upsert();
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$wpdb->update(
$wpdb->posts,
array( 'guid' => sanitize_url( $target ) ),
array( 'ID' => sanitize_key( $origin_id ) )
);
// Clear the cache.
wp_cache_delete( $origin_id, 'posts' );
return;
}
/*
* If the new target is followed, and the origin is followed,
* move users and delete the origin follower.
*/
if ( $target_follower && $origin_follower ) {
$origin_users = \get_post_meta( $origin_follower->get__id(), '_activitypub_user_id', false );
$target_users = \get_post_meta( $target_follower->get__id(), '_activitypub_user_id', false );
// Get all user ids from $origin_users that are not in $target_users.
$users = \array_diff( $origin_users, $target_users );
foreach ( $users as $user_id ) {
\add_post_meta( $target_follower->get__id(), '_activitypub_user_id', $user_id );
}
$origin_follower->delete();
}
}
/**
* Convert the object and origin to the correct format.
*
* @param \Activitypub\Activity\Activity $activity The Activity object.
* @return \Activitypub\Activity\Activity The filtered Activity object.
*/
public static function outbox_activity( $activity ) {
if ( 'Move' === $activity->get_type() ) {
$activity->set_object( object_to_uri( $activity->get_object() ) );
$activity->set_origin( $activity->get_actor() );
$activity->set_target( $activity->get_object() );
}
return $activity;
}
/**
* Extract the target from the activity.
*
* The ActivityStreams spec define the `target` attribute as the
* destination of the activity, but Mastodon uses the `object`
* attribute to move profiles.
*
* @param array $activity The JSON "Move" Activity.
*
* @return string|null The target URI or null if not found.
*/
private static function extract_target( $activity ) {
if ( ! empty( $activity['target'] ) ) {
return object_to_uri( $activity['target'] );
}
if ( ! empty( $activity['object'] ) ) {
return object_to_uri( $activity['object'] );
}
return null;
}
/**
* Extract the origin from the activity.
*
* The ActivityStreams spec define the `origin` attribute as source
* of the activity, but Mastodon uses the `actor` attribute as source
* to move profiles.
*
* @param array $activity The JSON "Move" Activity.
*
* @return string|null The origin URI or null if not found.
*/
private static function extract_origin( $activity ) {
if ( ! empty( $activity['origin'] ) ) {
return object_to_uri( $activity['origin'] );
}
if ( ! empty( $activity['actor'] ) ) {
return object_to_uri( $activity['actor'] );
}
return null;
}
/**
* Verify the move.
*
* @param array $target_object The target object.
* @param array $origin_object The origin object.
*
* @return bool True if the move is verified, false otherwise.
*/
private static function verify_move( $target_object, $origin_object ) {
// Check if both objects are valid.
if ( \is_wp_error( $target_object ) || \is_wp_error( $origin_object ) ) {
return false;
}
// Check if both objects are persons.
if ( 'Person' !== $target_object['type'] || 'Person' !== $origin_object['type'] ) {
return false;
}
// Check if the target and origin are not the same.
if ( $target_object['id'] === $origin_object['id'] ) {
return false;
}
// Check if the target has an alsoKnownAs property.
if ( empty( $target_object['also_known_as'] ) ) {
return false;
}
// Check if the origin is in the alsoKnownAs property of the target.
if ( ! in_array( $origin_object['id'], $target_object['also_known_as'], true ) ) {
return false;
}
// Check if the origin has a movedTo property.
if ( empty( $origin_object['movedTo'] ) ) {
return false;
}
// Check if the movedTo property of the origin is the target.
if ( $origin_object['movedTo'] !== $target_object['id'] ) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,90 @@
<?php
/**
* Undo handler file.
*
* @package Activitypub
*/
namespace Activitypub\Handler;
use Activitypub\Collection\Actors;
use Activitypub\Collection\Followers;
use Activitypub\Comment;
use function Activitypub\object_to_uri;
/**
* Handle Undo requests.
*/
class Undo {
/**
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
\add_action(
'activitypub_inbox_undo',
array( self::class, 'handle_undo' ),
10,
2
);
}
/**
* Handle "Unfollow" requests.
*
* @param array $activity The JSON "Undo" Activity.
* @param int|null $user_id The ID of the user who initiated the "Undo" activity.
*/
public static function handle_undo( $activity, $user_id ) {
if (
! isset( $activity['object']['type'] ) ||
! isset( $activity['object']['object'] )
) {
return;
}
$type = $activity['object']['type'];
$state = false;
// Handle "Unfollow" requests.
if ( 'Follow' === $type ) {
$id = object_to_uri( $activity['object']['object'] );
$user = Actors::get_by_resource( $id );
if ( ! $user || is_wp_error( $user ) ) {
// If we can not find a user, we can not initiate a follow process.
return;
}
$user_id = $user->get__id();
$actor = object_to_uri( $activity['actor'] );
$state = Followers::remove_follower( $user_id, $actor );
}
// Handle "Undo" requests for "Like" and "Create" activities.
if ( in_array( $type, array( 'Like', 'Create', 'Announce' ), true ) ) {
if ( ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS ) {
return;
}
$object_id = object_to_uri( $activity['object'] );
$comment = Comment::object_id_to_comment( esc_url_raw( $object_id ) );
if ( empty( $comment ) ) {
return;
}
$state = wp_delete_comment( $comment, true );
}
/**
* Fires after an "Undo" activity has been handled.
*
* @param array $activity The JSON "Undo" Activity.
* @param int|null $user_id The ID of the user who initiated the "Undo" activity otherwise null.
* @param mixed $state The state of the "Undo" activity.
*/
do_action( 'activitypub_handled_undo', $activity, $user_id, $state );
}
}

View File

@ -0,0 +1,125 @@
<?php
/**
* Update handler file.
*
* @package Activitypub
*/
namespace Activitypub\Handler;
use Activitypub\Collection\Followers;
use Activitypub\Collection\Interactions;
use function Activitypub\get_remote_metadata_by_actor;
/**
* Handle Update requests.
*/
class Update {
/**
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
\add_action(
'activitypub_inbox_update',
array( self::class, 'handle_update' )
);
}
/**
* Handle "Update" requests.
*
* @param array $activity The Activity object.
*/
public static function handle_update( $activity ) {
$object_type = isset( $activity['object']['type'] ) ? $activity['object']['type'] : '';
switch ( $object_type ) {
/*
* Actor Types.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#actor-types
*/
case 'Person':
case 'Group':
case 'Organization':
case 'Service':
case 'Application':
self::update_actor( $activity );
break;
/*
* Object and Link Types.
*
* @see https://www.w3.org/TR/activitystreams-vocabulary/#object-types
*/
case 'Note':
case 'Article':
case 'Image':
case 'Audio':
case 'Video':
case 'Event':
case 'Document':
self::update_interaction( $activity );
break;
/*
* Minimal Activity.
*
* @see https://www.w3.org/TR/activitystreams-core/#example-1
*/
default:
break;
}
}
/**
* Update an Interaction.
*
* @param array $activity The Activity object.
*/
public static function update_interaction( $activity ) {
$commentdata = Interactions::update_comment( $activity );
$reaction = null;
if ( ! empty( $commentdata['comment_ID'] ) ) {
$state = 1;
$reaction = \get_comment( $commentdata['comment_ID'] );
} else {
$state = $commentdata;
}
/**
* Fires after an Update activity has been handled.
*
* @param array $activity The complete Update activity data.
* @param null $user Always null for Update activities.
* @param int|array $state 1 if comment was updated successfully, error data otherwise.
* @param \WP_Comment|null $reaction The updated comment object if successful, null otherwise.
*/
\do_action( 'activitypub_handled_update', $activity, null, $state, $reaction );
}
/**
* Update an Actor.
*
* @param array $activity The Activity object.
*/
public static function update_actor( $activity ) {
// Update cache.
$actor = get_remote_metadata_by_actor( $activity['actor'], false );
if ( ! $actor || \is_wp_error( $actor ) || ! isset( $actor['id'] ) ) {
return;
}
$follower = Followers::get_follower_by_actor( $actor['id'] );
if ( ! $follower ) {
return;
}
$follower->from_array( $actor );
$follower->upsert();
}
}