400 ) ); } else { $result = Inbox_Collection::undo( object_to_uri( $activity['object'] ), $actor ); } if ( $result && ! \is_wp_error( $result ) ) { $success = true; } /** * Fires after an ActivityPub Undo activity has been handled. * * @param array $activity The ActivityPub activity data. * @param int[] $user_ids The local user IDs. * @param bool $success True on success, false on failure. * @param \WP_Comment|string $result The target, based on the activity that is being undone. */ \do_action( 'activitypub_handled_undo', $activity, (array) $user_ids, $success, $result ); } /** * 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 ) { $activity = $request->get_json_params(); if ( empty( $activity['type'] ) ) { return false; } if ( 'Undo' !== $activity['type'] ) { return $valid; } if ( ! isset( $activity['actor'], $activity['object'] ) ) { return false; } if ( ! \is_array( $activity['object'] ) && ! \is_string( $activity['object'] ) ) { return false; } if ( \is_array( $activity['object'] ) && ! isset( $activity['object']['id'] ) ) { return false; } return $valid; } }