Skip to content

Conversation

pfefferle
Copy link
Member

@pfefferle pfefferle commented Oct 20, 2025

Introduces a new 'activitypub_create_posts' option to control whether posts can be created or updated via ActivityPub. Updates Posts::add and Posts::update to require a user ID and store it in post meta. Adjusts handlers and tests to accommodate the new parameter and option.

Proposed changes:

  • Adds a new 'activitypub_create_posts' option that defaults to false, requiring explicit opt-in for post creation/updates
  • Updates Posts::add and Posts::update methods to require and store user ID in post meta
  • Modifies handlers to check the new option before allowing post operations

Other information:

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

Testing instructions:

  • Go to '..'

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

Introduces a new 'activitypub_create_posts' option to control whether posts can be created or updated via ActivityPub. Updates Posts::add and Posts::update to require a user ID and store it in post meta. Adjusts handlers and tests to accommodate the new parameter and option.
The tests for create and update handlers now explicitly set and delete the 'activitypub_create_posts' option before and after execution. This ensures a consistent test environment and prevents side effects between tests.
@pfefferle pfefferle requested review from Copilot and obenland October 20, 2025 12:38
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 introduces a new configuration option to control whether posts can be created or updated via ActivityPub by default, disabling this functionality unless explicitly enabled. It also enhances post tracking by associating ActivityPub posts with local user IDs.

  • Adds a new 'activitypub_create_posts' option that defaults to false, requiring explicit opt-in for post creation/updates
  • Updates Posts::add and Posts::update methods to require and store user ID in post meta
  • Modifies handlers to check the new option before allowing post operations

Reviewed Changes

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

Show a summary per file
File Description
includes/wp-admin/class-settings.php Registers the new 'activitypub_create_posts' boolean setting
includes/handler/class-create.php Adds option check before creating posts and passes user_id parameter
includes/handler/class-update.php Adds option check before updating posts and passes user_id parameter
includes/collection/class-posts.php Updates add/update methods to require user_id and store it in post meta
tests/phpunit/tests/includes/handler/class-test-create.php Enables option for test and cleans up afterward
tests/phpunit/tests/includes/handler/class-test-update.php Enables option for test and cleans up afterward
tests/phpunit/tests/includes/collection/class-test-posts.php Updates test calls to include required user_id parameter

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

The '_activitypub_user_id' meta is now added using add_post_meta after the post is inserted, rather than via the meta_input argument in wp_insert_post. This change ensures consistent handling of post meta and aligns with how other meta fields are added.
@pfefferle pfefferle added the Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. label Oct 20, 2025
@pfefferle pfefferle marked this pull request as ready for review October 20, 2025 14:23
@pfefferle pfefferle added this to the Reader v1 milestone Oct 20, 2025
Registers the '_activitypub_user_id' post meta for the custom post type, allowing storage of the local user ID that received the activity. This meta field is defined as an integer, single value, with a description and sanitization callback.
@pfefferle pfefferle merged commit 13ef7ea into trunk Oct 21, 2025
13 checks passed
@pfefferle pfefferle deleted the posts-tweaks branch October 21, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Collections [Feature] WP Admin Skip Changelog Disables the "Changelog Updated" action for PRs where changelog entries are not necessary. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants