PluginProbe
ActivityPub / 7.8.4
ActivityPub v7.8.4
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/handler/class-delete.php +14 -38 9.0.27.8.4 View file →
@@ -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,14 +23,14 @@
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' ) );
32 - \add_action( 'post_activitypub_add_to_outbox', array( self::class, 'maybe_bury' ), 10, 2 );
32 + \add_action( 'post_activitypub_add_to_outbox', array( self::class, 'post_add_to_outbox' ), 10, 2 );
33 33 }
34 34
35 35 /**
36 36 * Handles "Delete" requests.
@@ -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;
@@ -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;
@@ -341,27 +328,16 @@
341 328 return $activity;
342 329 }
343 330
344 331 /**
345 - * Add a URL to the tombstone registry when a Delete activity is sent.
332 + * Add the activity to the outbox.
346 333 *
347 334 * @param int $outbox_id The ID of the outbox activity.
348 335 * @param \Activitypub\Activity\Activity $activity The Activity object.
349 336 */
350 - public static function maybe_bury( $outbox_id, $activity ) {
351 - if ( 'Delete' !== $activity->get_type() ) {
352 - return;
353 - }
354 -
355 - $object = $activity->get_object();
356 -
357 - if ( ! $object ) {
358 - return;
359 - }
360 -
361 - Tombstone::bury( object_to_uri( $object ) );
362 -
363 - if ( \is_object( $object ) ) {
364 - Tombstone::bury( $object->get_id(), $object->get_url() );
337 + public static function post_add_to_outbox( $outbox_id, $activity ) {
338 + // Set Tombstones for deleted objects.
339 + if ( 'Delete' === $activity->get_type() ) {
340 + Tombstone::bury( object_to_uri( $activity->get_object() ) );
365 341 }
366 342 }
367 343 }