Skip to content

Conversation

pfefferle
Copy link
Member

@pfefferle pfefferle commented Aug 4, 2025

This PR implements a self-destruct feature for ActivityPub that allows users to remove their blog from the Fediverse by sending Delete activities to all followers. The implementation includes a CLI command, completion tracking, and admin notifications.

Screenshot 2025-08-06 at 12 35 39

Proposed changes:

  • Implements the wp activitypub self_destruct CLI command with confirmation prompts and progress tracking
  • Adds completion detection logic that monitors for pending Delete activities and notifies when the process finishes
  • Provides admin notice functionality to inform users when the self-destruct process is complete

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Run wp activitypub self_destruct in the CLI
  • Check the Outbox for Delete Activities

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Adds a self-destruct feature to remove a blog from the Fediverse by sending Delete activities to followers.

Improves the self_destruct method to schedule deletion for all users with the 'activitypub' capability, logs each scheduled user, and updates messaging for clarity. Adds an option to mark the deletion process and instructs users to keep the plugin active until completion.
Enhanced the self_destruct command to provide clearer warnings, detailed process steps, and progress feedback when deleting a blog from the Fediverse. Added checks for user existence, improved error handling, and clarified next steps for users after scheduling deletions.
@pfefferle pfefferle added this to the User Delete milestone Aug 6, 2025
Implements a mechanism to check when all Delete activities for ActivityPub self-destruct are processed, removes the self-destruct flag, and displays an admin notice upon completion. Enhances user feedback and ensures proper cleanup after self-destruct operations.
@pfefferle pfefferle marked this pull request as ready for review August 6, 2025 11:12
@Copilot Copilot AI review requested due to automatic review settings August 6, 2025 11:12
Copilot

This comment was marked as outdated.

pfefferle and others added 2 commits August 6, 2025 13:15
Changed the action hook from 'activitypub_self_destruct_processing_complete' to 'activitypub_outbox_processing_complete' and updated the method signature for check_self_destruct_completion to accept only inboxes and JSON. Adjusted post type, status, and meta key in the pending deletes query for consistency with Outbox implementation.
@pfefferle pfefferle self-assigned this Aug 6, 2025
@pfefferle pfefferle requested review from obenland and Copilot August 6, 2025 11:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a self-destruct feature for ActivityPub that allows users to completely remove their blog from the Fediverse by sending Delete activities to all followers. The implementation provides a CLI command with confirmation prompts, automatic completion tracking, and admin notifications when the process finishes.

  • Adds wp activitypub self_destruct CLI command with safety confirmations and progress tracking
  • Implements completion detection logic that monitors pending Delete activities and notifies when finished
  • Provides admin notice functionality to inform users when the self-destruct process is complete

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
includes/class-cli.php Implements the main self-destruct CLI command with user confirmation, progress tracking, and scheduling of Delete activities
includes/class-scheduler.php Adds completion detection logic to monitor pending Delete activities and trigger notifications
includes/wp-admin/class-admin.php Adds admin notice display for self-destruct completion notifications
.github/changelog/2046-from-description Changelog entry for the new feature

Replaces direct parameters with an Activity object when adding a 'Delete' activity to the outbox. This change improves consistency and leverages the Activity class for better structure.
</p>
</div>
<?php
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this being triggered from CLI, how about sending an email on completion instead?

\add_option( 'activitypub_self_destruct', true );

// Hook into outbox processing completion to notify when self-destruct is done.
\add_action( 'activitypub_outbox_processing_complete', array( Scheduler::class, 'check_self_destruct_completion' ), 10, 2 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? Any outbox processing should happen in separate threads where this action would not be added.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any idea where to put this instead? does it cost too much to add the hook, to be called on every activitypub_outbox_processing_complete call?

Copy link
Member

@obenland obenland Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably not too expensive to put into the Dispatcher, but kind of a bummer given that this will almost never run.

Do we need the notification? Could we give them a CLI command to keep track of the scheduled events manually? Like, tell them to check wp cron event list XYZ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This felt like the best UX. We should get sure that this delete is properly processed, because otherwise this could end up in a big inconsistancy that can never be properly cleaned up!?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants