updated plugin ActivityPub version 5.8.0

This commit is contained in:
2025-04-29 21:19:06 +00:00
committed by Gitium
parent 19dfd317cc
commit fdfbf76539
166 changed files with 14119 additions and 7163 deletions

View File

@ -7,6 +7,7 @@
namespace Activitypub\Handler;
use Activitypub\Collection\Followers;
use Activitypub\Collection\Interactions;
use function Activitypub\get_remote_metadata_by_actor;
@ -26,9 +27,9 @@ class Update {
}
/**
* Handle "Update" requests
* Handle "Update" requests.
*
* @param array $activity The activity-object.
* @param array $activity The Activity object.
*/
public static function handle_update( $activity ) {
$object_type = isset( $activity['object']['type'] ) ? $activity['object']['type'] : '';
@ -75,7 +76,7 @@ class Update {
/**
* Update an Interaction.
*
* @param array $activity The activity-object.
* @param array $activity The Activity object.
*/
public static function update_interaction( $activity ) {
$commentdata = Interactions::update_comment( $activity );
@ -88,18 +89,37 @@ class Update {
$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.
* @param array $activity The Activity object.
*/
public static function update_actor( $activity ) {
// Update cache.
get_remote_metadata_by_actor( $activity['actor'], false );
$actor = get_remote_metadata_by_actor( $activity['actor'], false );
// @todo maybe also update all interactions.
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();
}
}