get_error_code() ) { $updated = false; } } // There is no object to update, try to trigger create instead. if ( ! $updated ) { /** * Fires when a Create activity is received for an existing object. * * @param array $activity The activity-object. * @param int[] $user_ids The ids of the local blog-users. * @param \Activitypub\Activity\Activity $activity_object The activity object. */ \do_action( 'activitypub_inbox_create', $activity, $user_ids, $activity_object ); return false; } $success = ( $result && ! \is_wp_error( $result ) ); /** * Fires after an ActivityPub Update activity has been handled. * * @param array $activity The ActivityPub activity data. * @param int[]|null $user_ids The local user IDs. * @param bool $success True on success, false otherwise. * @param \WP_Comment|\WP_Post|\WP_Error $result The updated post, comment, or error. */ \do_action( 'activitypub_handled_update', $activity, (array) $user_ids, $success, $result ); } /** * Update an Actor. * * @param array $activity The Activity object. * @param int[]|null $user_ids The user IDs. Always null for Update activities. */ public static function update_actor( $activity, $user_ids ) { // Update cache. $actor = get_remote_metadata_by_actor( $activity['actor'], false ); if ( ! $actor || \is_wp_error( $actor ) || ! isset( $actor['id'] ) ) { $state = new \WP_Error( 'activitypub_update_failed', 'Update failed: could not fetch actor data' ); } else { $state = Remote_Actors::upsert( $actor ); } /** * Fires after an ActivityPub Update activity has been handled. * * @param array $activity The ActivityPub activity data. * @param int[] $user_ids The local user IDs. * @param int|\WP_Error $state Actor post ID on success, WP_Error on failure. * @param array $actor Remote actor meta data. */ \do_action( 'activitypub_handled_update', $activity, (array) $user_ids, $state, $actor ); } }