| @@ -7,10 +7,10 @@ | ||
| 7 | 7 | |
| 8 | 8 | namespace Activitypub\Handler; |
| 9 | 9 | |
| 10 | 10 | use Activitypub\Collection\Interactions; |
| 11 | +use Activitypub\Collection\Posts; | |
| 11 | 12 | use Activitypub\Collection\Remote_Actors; |
| 12 | -use Activitypub\Collection\Remote_Posts; | |
| 13 | 13 | use Activitypub\Tombstone; |
| 14 | 14 | |
| 15 | 15 | use function Activitypub\object_to_uri; |
| 16 | 16 | |
| @@ -23,9 +23,9 @@ | ||
| 23 | 23 | */ |
| 24 | 24 | public static function init() { |
| 25 | 25 | \add_action( 'activitypub_inbox_delete', array( self::class, 'handle_delete' ), 10, 2 ); |
| 26 | 26 | \add_filter( 'activitypub_skip_inbox_storage', array( self::class, 'skip_inbox_storage' ), 10, 2 ); |
| 27 | - \add_filter( 'activitypub_defer_signature_verification', array( self::class, 'defer_signature_verification' ), 10, 3 ); | |
| 27 | + \add_filter( 'activitypub_defer_signature_verification', array( self::class, 'defer_signature_verification' ), 10, 2 ); | |
| 28 | 28 | \add_action( 'activitypub_delete_remote_actor_interactions', array( self::class, 'delete_interactions' ) ); |
| 29 | 29 | \add_action( 'activitypub_delete_remote_actor_posts', array( self::class, 'delete_posts' ) ); |
| 30 | 30 | |
| 31 | 31 | \add_filter( 'activitypub_get_outbox_activity', array( self::class, 'outbox_activity' ) ); |
| @@ -155,9 +155,9 @@ | ||
| 155 | 155 | public static function maybe_delete_follower( $activity ) { |
| 156 | 156 | $follower = Remote_Actors::get_by_uri( $activity['actor'] ); |
| 157 | 157 | |
| 158 | 158 | // Verify that Actor is deleted. |
| 159 | - if ( ! \is_wp_error( $follower ) && Tombstone::exists( $activity['actor'] ) ) { | |
| 159 | + if ( ! is_wp_error( $follower ) && Tombstone::exists( $activity['actor'] ) ) { | |
| 160 | 160 | self::maybe_delete_interactions( $follower->ID ); |
| 161 | 161 | self::maybe_delete_posts( $follower->ID ); |
| 162 | 162 | $state = Remote_Actors::delete( $follower->ID ); |
| 163 | 163 | } |
| @@ -219,12 +219,12 @@ | ||
| 219 | 219 | * |
| 220 | 220 | * @return bool True on success, false otherwise. |
| 221 | 221 | */ |
| 222 | 222 | public static function delete_posts( $id ) { |
| 223 | - $posts = Remote_Posts::get_by_remote_actor_id( $id ); | |
| 223 | + $posts = Posts::get_by_remote_actor_id( $id ); | |
| 224 | 224 | |
| 225 | 225 | foreach ( $posts as $post ) { |
| 226 | - Remote_Posts::delete( $post->ID ); | |
| 226 | + Posts::delete( $post->ID ); | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | if ( $posts ) { |
| 230 | 230 | return true; |
| @@ -251,9 +251,9 @@ | ||
| 251 | 251 | |
| 252 | 252 | if ( $comments && Tombstone::exists( $id ) ) { |
| 253 | 253 | foreach ( $comments as $comment ) { |
| 254 | 254 | // WordPress will automatically delete all comment meta including _activitypub_remote_actor_id. |
| 255 | - \wp_delete_comment( $comment->comment_ID, true ); | |
| 255 | + wp_delete_comment( $comment->comment_ID, true ); | |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | return true; |
| 259 | 259 | } |
| @@ -272,9 +272,9 @@ | ||
| 272 | 272 | $id = object_to_uri( $activity['object'] ); |
| 273 | 273 | |
| 274 | 274 | // Check if the object exists and is a tombstone. |
| 275 | 275 | if ( Tombstone::exists( $id ) ) { |
| 276 | - return Remote_Posts::delete_by_guid( $id ); | |
| 276 | + return Posts::delete_by_guid( $id ); | |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | return false; |
| 280 | 280 | } |
| @@ -297,27 +297,14 @@ | ||
| 297 | 297 | |
| 298 | 298 | /** |
| 299 | 299 | * Defer signature verification for `Delete` requests. |
| 300 | 300 | * |
| 301 | - * Endpoints that opt in to mandatory signing by calling | |
| 302 | - * `verify_signature( $request, true )` must not be overridden — the | |
| 303 | - * Delete carve-out is only for the default inbox path where the | |
| 304 | - * remote actor's keys may legitimately be gone before the Delete | |
| 305 | - * arrives. | |
| 301 | + * @param bool $defer Whether to defer signature verification. | |
| 302 | + * @param \WP_REST_Request $request The request object. | |
| 306 | 303 | * |
| 307 | - * @since 8.2.0 The `$force_signature` parameter is now respected. | |
| 308 | - * | |
| 309 | - * @param bool $defer Whether to defer signature verification. | |
| 310 | - * @param \WP_REST_Request $request The request object. | |
| 311 | - * @param bool $force_signature Whether the caller has forced signature verification. | |
| 312 | - * | |
| 313 | 304 | * @return bool Whether to defer signature verification. |
| 314 | 305 | */ |
| 315 | - public static function defer_signature_verification( $defer, $request, $force_signature = false ) { | |
| 316 | - if ( $force_signature ) { | |
| 317 | - return $defer; | |
| 318 | - } | |
| 319 | - | |
| 306 | + public static function defer_signature_verification( $defer, $request ) { | |
| 320 | 307 | $json = $request->get_json_params(); |
| 321 | 308 | |
| 322 | 309 | if ( isset( $json['type'] ) && 'Delete' === $json['type'] ) { |
| 323 | 310 | return true; |