Skip to content

Post by Email abilities: register status read + regenerate-address via Registrar#48770

Draft
enejb wants to merge 1 commit into
trunkfrom
add/ship-post-by-email-abilities
Draft

Post by Email abilities: register status read + regenerate-address via Registrar#48770
enejb wants to merge 1 commit into
trunkfrom
add/ship-post-by-email-abilities

Conversation

@enejb
Copy link
Copy Markdown
Member

@enejb enejb commented May 13, 2026

Summary

Adds two abilities for the Post by Email module via the standard wp-abilities/v1 REST surface, mirroring the Monitor abilities pattern.

  • jetpack-post-by-email/get-status — per-user read of { active, address, address_active, last_used_at }. address is null when the user has not enabled PBE; last_used_at is reserved (always null in this release) since the remote service does not currently expose last-used metadata.
  • jetpack-post-by-email/regenerate-address — rotates the user's address; annotated readonly=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_Abilities extends Registrar, lives at projects/plugins/jetpack/modules/post-by-email/abilities/class-post-by-email-abilities.php (Case A — module-colocated).
  • Wired from 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).
  • Protected seams (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.
  • Precondition and transport failures surface as WP_Error with the shared jetpack_post_by_email_* vocabulary so callers (agents) get an actionable next step rather than opaque nulls.
  • Mirrors the post-rotate response to the legacy post_by_email_address{user_id} option so Jetpack_Core_Json_Api_Endpoints::get_remote_value stays in sync.

Test plan

  • CI: Post_By_Email_Abilities_Test passes — 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.
  • On a connected WP 6.9+ site with the jetpack_wp_abilities_enabled filter true and the Post by Email module active, confirm /wp-json/wp-abilities/v1/abilities lists jetpack-post-by-email/get-status and jetpack-post-by-email/regenerate-address, and get-status returns the documented shape.
  • Deactivate the Post by Email module and confirm the two slugs disappear from wp_get_abilities().

Local phpunit could not run in this environment (the host's phpunit-select-config shim is not on PATH outside Docker) — relying on CI.

Plan reference: §3.3 (Post by Email).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the add/ship-post-by-email-abilities branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/ship-post-by-email-abilities

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Feature] Post By Email [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests labels May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add testing instructions.
  • 🔴 Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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:

## Testing instructions:

* Go to '..'
*

🔴 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:

## Does this pull request change what data or activity we track or use?

My PR adds *x* and *y*.

Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 13, 2026
@jp-launch-control
Copy link
Copy Markdown

Code Coverage Summary

Cannot generate coverage summary while tests are failing. 🤐

Please fix the tests, or re-run the Code coverage job if it was something being flaky.

Full summary · PHP report · JS report

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

Labels

[Feature] Post By Email [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant