PluginProbe
ActivityPub / 9.2.1
ActivityPub v9.2.1
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
activitypub / includes / cli / class-actor-command.php

class-actor-command.php in ActivityPub 9.2.1, at includes/cli/class-actor-command.php

79 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Actor CLI Command.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub\Cli;
9
10 use Activitypub\Collection\Actors;
11 use Activitypub\Scheduler\Actor;
12
13 /**
14 * Manage ActivityPub actors.
15 *
16 * @package Activitypub
17 */
18 class Actor_Command extends \WP_CLI_Command {
19
20 /**
21 * Delete an Actor from the Fediverse.
22 *
23 * Sends a Delete activity to all followers to remove the actor from
24 * federated instances.
25 *
26 * ## OPTIONS
27 *
28 * <id>
29 * : The ID of the Actor (user ID).
30 *
31 * ## EXAMPLES
32 *
33 * # Delete actor with user ID 1
34 * $ wp activitypub actor delete 1
35 *
36 * @subcommand delete
37 *
38 * @param array $args The positional arguments.
39 * @param array $assoc_args The associative arguments (unused).
40 */
41 public function delete( $args, $assoc_args ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
42 // Only the blog actor (0) and real users (positive IDs) can be deleted; negative IDs (e.g. the former -1 application ID) are never valid actors.
43 if ( (int) $args[0] < Actors::BLOG_USER_ID ) {
44 \WP_CLI::error( \sprintf( 'No deletable actor found for ID "%s".', $args[0] ) );
45 }
46
47 \add_filter( 'activitypub_user_can_activitypub', '__return_true' );
48 Actor::schedule_user_delete( $args[0] );
49 \remove_filter( 'activitypub_user_can_activitypub', '__return_true' );
50 \WP_CLI::success( '"Delete" activity is queued.' );
51 }
52
53 /**
54 * Update an Actor on the Fediverse.
55 *
56 * Sends an Update activity to all followers to refresh the actor profile
57 * on federated instances.
58 *
59 * ## OPTIONS
60 *
61 * <id>
62 * : The ID of the Actor (user ID).
63 *
64 * ## EXAMPLES
65 *
66 * # Update actor with user ID 1
67 * $ wp activitypub actor update 1
68 *
69 * @subcommand update
70 *
71 * @param array $args The positional arguments.
72 * @param array $assoc_args The associative arguments (unused).
73 */
74 public function update( $args, $assoc_args ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
75 Actor::schedule_profile_update( $args[0] );
76 \WP_CLI::success( '"Update" activity is queued.' );
77 }
78 }
79