Skip to content

Rework Follower Structure #1759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 131 commits into from
Jun 20, 2025
Merged

Rework Follower Structure #1759

merged 131 commits into from
Jun 20, 2025

Conversation

pfefferle
Copy link
Member

@pfefferle pfefferle commented Jun 3, 2025

Rework follower structure to enable reuse of the pattern for the following mechanism.

This is the first major change to the follower structure, enabling the unified storage of "Remote Actors" — such as followers, followings, and mentioned actors. The first step is to migrate all generic functionality to the Actors collection and use the Followers collection solely to map an actor to a local user.

The next steps will be (further PRs):

  • Deprecate the Follower model in favor of the generic Actor model
  • Establish class structure for Followings
  • Add an internal API for managing Followings

Proposed changes:

  • Move Actor handling to the Actors collection to enable a unified structure for followers and followings
  • Avoid transforming post-type objects into Actor objects for internal operations to reduce resource usage and simplify handling
  • Update tests

Other information:

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

Testing instructions:

  • No user facing changes
  • See tests

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

Reworked follower structure to simplify handling and enable reuse for following mechanism.

Copy link
Member

@obenland obenland left a comment

Choose a reason for hiding this comment

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

There are a few undefined method and properties calls that would benefit from another iteration before this gets merged

@pfefferle pfefferle requested review from obenland and Copilot June 19, 2025 16:13
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 overhauls the follower subsystem by consolidating all remote-actor storage and operations into a single Actors custom post type.
Key changes:

  • Redirect all follower CRUD and error-tracking APIs to the new Actors collection and deprecate the standalone Follower model.
  • Update Follow, Update, Move, Delete handlers to upsert and query via Actors methods instead of Follower.
  • Adjust scheduler hooks and all tests to work with Actors (WP_Post) rather than the old Follower model.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
includes/model/class-follower.php Refactored delete and error methods to delegate to Actors.
includes/collection/class-followers.php Updated metadata APIs; remove_follower now uses post meta.
includes/handler/class-follow.php Use WP_Post ($remote_actor) instead of Follower; changed queue_accept actor.
includes/handler/class-move.php Handle Move via Actors CPT (get_remote_by_uri, upsert).
includes/class-scheduler.php Renamed cron hooks for remote actor updates and cleanup.
Comments suppressed due to low confidence (1)

includes/handler/class-follow.php:114

  • In queue_accept, setting the activity actor to the follower's guid is incorrect. The Accept must be sent by the local user, so you should use Actors::get_by_id($user_id)->get_id() instead.
		$activity->set_actor( $remote_actor->guid );

Copy link
Member

@obenland obenland left a comment

Choose a reason for hiding this comment

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

Let's merge and iterate if needed. Nice work!

*
* @return string Hopefully the name of the Follower.
*/
function extract_name_from_uri( $uri ) {
Copy link
Member

Choose a reason for hiding this comment

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

I worry that moving it here will make it harder to refactor and remove.

@pfefferle pfefferle merged commit d60012a into trunk Jun 20, 2025
10 of 11 checks passed
@pfefferle pfefferle deleted the remove/follower-model branch June 20, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Collections [Focus] Compatibility Ensuring the plugin plays well with other plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants