-
Notifications
You must be signed in to change notification settings - Fork 85
Disable Post Create
and Update
by default
#2341
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
Conversation
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.
There was a problem hiding this 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.
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.
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:
Other information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message