Post by Email abilities: register status read + regenerate-address via Registrar#48770
Post by Email abilities: register status read + regenerate-address via Registrar#48770enejb wants to merge 1 commit into
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so: 🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCannot generate coverage summary while tests are failing. 🤐 Please fix the tests, or re-run the Code coverage job if it was something being flaky. |
Summary
Adds two abilities for the Post by Email module via the standard
wp-abilities/v1REST surface, mirroring the Monitor abilities pattern.jetpack-post-by-email/get-status— per-user read of{ active, address, address_active, last_used_at }.addressisnullwhen the user has not enabled PBE;last_used_atis reserved (alwaysnullin this release) since the remote service does not currently expose last-used metadata.jetpack-post-by-email/regenerate-address— rotates the user's address; annotatedreadonly=false,destructive=true(invalidates the previous address — saved drafts pointing at it will no longer reach the site),idempotent=false(each call mints a new address).Both abilities are gated on
is_user_logged_in()— Post by Email is a per-user feature; the remote service uses the caller's Jetpack user token, so users cannot view or rotate anyone else's address.Implementation
Post_By_Email_AbilitiesextendsRegistrar, lives atprojects/plugins/jetpack/modules/post-by-email/abilities/class-post-by-email-abilities.php(Case A — module-colocated).modules/post-by-email.php, so abilities only register while the Post by Email module is active (load_modules()only includes the module file when it's on).is_user_connected_to_jetpack,fetch_address,apply_regenerate) allow tests to drive both happy paths and remote-failure paths without a Jetpack token fixture or live IXR endpoint.WP_Errorwith the sharedjetpack_post_by_email_*vocabulary so callers (agents) get an actionable next step rather than opaque nulls.post_by_email_address{user_id}option soJetpack_Core_Json_Api_Endpoints::get_remote_valuestays in sync.Test plan
Post_By_Email_Abilities_Testpasses — Registrar wiring (gate filter, lifecycle hooks, per-ability allow-list, category auto-injection), permission callbacks, execute callbacks (module-inactive, not-connected, happy paths, service-unreachable, non-idempotency across calls), and the activation-gating bootstrap assertion.jetpack_wp_abilities_enabledfilter true and the Post by Email module active, confirm/wp-json/wp-abilities/v1/abilitieslistsjetpack-post-by-email/get-statusandjetpack-post-by-email/regenerate-address, andget-statusreturns the documented shape.wp_get_abilities().Local phpunit could not run in this environment (the host's
phpunit-select-configshim is not on PATH outside Docker) — relying on CI.Plan reference: §3.3 (Post by Email).