6e7f82bf42
* init * save source id * fix delete and add improve undo * test new functions * add support for threaded comments * some formatting * check if URL is no longer available ...and returns either status 410 or 404. * improve delete handler * improve update handler * `object` and `actor` are already required by the inbox endpoint * fix typo * simplify queries * cosmetics * fix unit tests * schedule delete comments of deleted actor (#575) * schedule delete comments of deleted actor * phpcs --------- Co-authored-by: Django Doucet <django.doucet@webdevstudios.com> * move `get_comments_by_actor` to interactions collection * consistent wording * implement Tombstone * fix follow issue * fix inbox-create * added missing namespace * check if field is set * Fix namespacing issue * update profile and update interaction * fields are already validated by inbox * optimize avatar handling --------- Co-authored-by: Django <mediaformat.ux@gmail.com> Co-authored-by: Django Doucet <django.doucet@webdevstudios.com>
31 lines
706 B
PHP
31 lines
706 B
PHP
<?php
|
|
namespace Activitypub\Handler;
|
|
|
|
use Activitypub\Collection\Followers;
|
|
|
|
/**
|
|
* Handle Undo requests
|
|
*/
|
|
class Undo {
|
|
/**
|
|
* Initialize the class, registering WordPress hooks
|
|
*/
|
|
public static function init() {
|
|
\add_action( 'activitypub_inbox_undo', array( self::class, 'handle_undo' ), 10, 2 );
|
|
}
|
|
|
|
/**
|
|
* Handle "Unfollow" requests
|
|
*
|
|
* @param array $activity The JSON "Undo" Activity
|
|
* @param int $user_id The ID of the ID of the WordPress User
|
|
*/
|
|
public static function handle_undo( $activity, $user_id ) {
|
|
if (
|
|
isset( $activity['object']['type'] ) &&
|
|
'Follow' === $activity['object']['type']
|
|
) {
|
|
Followers::remove_follower( $user_id, $activity['actor'] );
|
|
}
|
|
}
|
|
}
|