| 1 |
<?php |
| 2 |
namespace Activitypub\Handler; |
| 3 |
|
| 4 |
use Activitypub\Collection\Followers; |
| 5 |
|
| 6 |
/** |
| 7 |
* Handle Undo requests |
| 8 |
*/ |
| 9 |
class Undo { |
| 10 |
/** |
| 11 |
* Initialize the class, registering WordPress hooks |
| 12 |
*/ |
| 13 |
public static function init() { |
| 14 |
\add_action( 'activitypub_inbox_undo', array( self::class, 'handle_undo' ), 10, 2 ); |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Handle "Unfollow" requests |
| 19 |
* |
| 20 |
* @param array $activity The JSON "Undo" Activity |
| 21 |
* @param int $user_id The ID of the ID of the WordPress User |
| 22 |
*/ |
| 23 |
public static function handle_undo( $activity, $user_id ) { |
| 24 |
if ( |
| 25 |
isset( $activity['object']['type'] ) && |
| 26 |
'Follow' === $activity['object']['type'] |
| 27 |
) { |
| 28 |
Followers::remove_follower( $user_id, $activity['actor'] ); |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
|