| @@ -14,13 +14,26 @@ | ||
| 14 | 14 | /** |
| 15 | 15 | * Initialize the class, registering WordPress hooks |
| 16 | 16 | */ |
| 17 | 17 | public static function init() { |
| 18 | - \add_action( 'activitypub_inbox_delete', array( self::class, 'handle_delete' ), 10, 2 ); | |
| 18 | + \add_action( | |
| 19 | + 'activitypub_inbox_delete', | |
| 20 | + array( self::class, 'handle_delete' ) | |
| 21 | + ); | |
| 22 | + | |
| 19 | 23 | // defer signature verification for `Delete` requests. |
| 20 | - \add_filter( 'activitypub_defer_signature_verification', array( self::class, 'defer_signature_verification' ), 10, 2 ); | |
| 24 | + \add_filter( | |
| 25 | + 'activitypub_defer_signature_verification', | |
| 26 | + array( self::class, 'defer_signature_verification' ), | |
| 27 | + 10, | |
| 28 | + 2 | |
| 29 | + ); | |
| 30 | + | |
| 21 | 31 | // side effect |
| 22 | - \add_action( 'activitypub_delete_actor_interactions', array( self::class, 'delete_interactions' ), 10, 1 ); | |
| 32 | + \add_action( | |
| 33 | + 'activitypub_delete_actor_interactions', | |
| 34 | + array( self::class, 'delete_interactions' ) | |
| 35 | + ); | |
| 23 | 36 | } |
| 24 | 37 | |
| 25 | 38 | /** |
| 26 | 39 | * Handles "Delete" requests. |
| @@ -27,9 +40,9 @@ | ||
| 27 | 40 | * |
| 28 | 41 | * @param array $activity The delete activity. |
| 29 | 42 | * @param int $user_id The ID of the user performing the delete activity. |
| 30 | 43 | */ |
| 31 | - public static function handle_delete( $activity, $user_id ) { | |
| 44 | + public static function handle_delete( $activity ) { | |
| 32 | 45 | $object_type = isset( $activity['object']['type'] ) ? $activity['object']['type'] : ''; |
| 33 | 46 | |
| 34 | 47 | switch ( $object_type ) { |
| 35 | 48 | // Actor Types |
| @@ -38,9 +51,9 @@ | ||
| 38 | 51 | case 'Group': |
| 39 | 52 | case 'Organization': |
| 40 | 53 | case 'Service': |
| 41 | 54 | case 'Application': |
| 42 | - self::maybe_delete_follower( $user_id, $activity ); | |
| 55 | + self::maybe_delete_follower( $activity ); | |
| 43 | 56 | break; |
| 44 | 57 | // Object and Link Types |
| 45 | 58 | // @see https://www.w3.org/TR/activitystreams-vocabulary/#object-types |
| 46 | 59 | case 'Note': |
| @@ -67,9 +80,8 @@ | ||
| 67 | 80 | |
| 68 | 81 | // check if Object is an Actor. |
| 69 | 82 | if ( $activity['actor'] === $activity['object'] ) { |
| 70 | 83 | self::maybe_delete_follower( $activity ); |
| 71 | - self::maybe_delete_interactions( $activity ); | |
| 72 | 84 | } else { // assume a interaction otherwise. |
| 73 | 85 | self::maybe_delete_interaction( $activity ); |
| 74 | 86 | } |
| 75 | 87 | // maybe handle Delete Activity for other Object Types. |
| @@ -87,8 +99,9 @@ | ||
| 87 | 99 | |
| 88 | 100 | // verify if Actor is deleted. |
| 89 | 101 | if ( $follower && Http::is_tombstone( $activity['actor'] ) ) { |
| 90 | 102 | $follower->delete(); |
| 103 | + self::maybe_delete_interactions( $activity ); | |
| 91 | 104 | } |
| 92 | 105 | } |
| 93 | 106 | |
| 94 | 107 | /** |