Skip to content

RTC: Send async admin notifications when non-admin is blocked by collaborator limit#47868

Draft
rcrdortiz wants to merge 6 commits intotrunkfrom
dotcom-16367-async-admin-notification-emailin-app-when-non-admin-is
Draft

RTC: Send async admin notifications when non-admin is blocked by collaborator limit#47868
rcrdortiz wants to merge 6 commits intotrunkfrom
dotcom-16367-async-admin-notification-emailin-app-when-non-admin-is

Conversation

@rcrdortiz
Copy link
Copy Markdown
Contributor

Summary

Fixes DOTCOM-16367

When a non-admin user is blocked from joining an editor session due to the collaborator limit, the plan owner (admin) may not be in the editor to see it. This PR adds async notifications so the admin is informed even when offline:

  • Bell notification via notes_send_callback — appears in the WP.com notification bell
  • Email notification — HTML email matching the in-editor RTC modal design (hero image, description, upgrade CTA)
  • Rate limiting — one notification set per (blog, post, blocked user) per 24h (filterable via wpcom_rtc_async_notification_interval)
  • Extracts wpcom_rtc_get_plan_owner_id() from the existing wpcom_rtc_is_plan_owner() so the owner ID is reusable

Changes

  • gutenberg-rtc-notices.php — new wpcom_rtc_get_plan_owner_id() function; wpcom_rtc_is_plan_owner() refactored to use it
  • class-wp-rest-rtc-notices.php — new methods: send_async_admin_notifications(), send_admin_bell_notification(), send_admin_email_notification(), build_email_html()
  • RTC_Notices_Test.php — tests for plan owner ID, rate limiting, email HTML output, bell notification guard, and integration with record_join_request

Test plan

  • Verify bell notification fires when a non-admin is blocked (requires WPCOM sandbox with notes_send_callback)
  • Verify email is sent to plan owner with correct content and upgrade link
  • Verify rate limiting: second block within 24h does not re-send
  • Verify wpcom_rtc_async_notification_interval filter works
  • Run PHP unit tests: jetpack docker phpunit -- --filter=RTC_Notices_Test
  • Review email HTML rendering in major email clients

🤖 Generated with Claude Code

…llaborator limit

When a non-admin user is blocked from joining an editor session due to
the collaborator limit, send bell and email notifications to the plan
owner so they are aware even when not in the editor.

- Extract wpcom_rtc_get_plan_owner_id() from wpcom_rtc_is_plan_owner()
- Add rate-limited async notification dispatch (bell + email) on join request
- Build HTML email matching the in-editor RTC modal design
- Add tests for plan owner ID, rate limiting, email HTML, and bell notification
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 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 (WordPress.com Site Helper), and enable the dotcom-16367-async-admin-notification-emailin-app-when-non-admin-is branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin dotcom-16367-async-admin-notification-emailin-app-when-non-admin-is

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
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

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*.

🔴 Action required: Please add missing changelog entries for the following projects: projects/packages/jetpack-mu-wpcom

Use the Jetpack CLI tool to generate changelog entries by running the following command: jetpack changelog add.
Alternatively, you can check the "Generate changelog entries" checkbox in the PR description to have them auto-generated.
Guidelines: /docs/writing-a-good-changelog-entry.md


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 Mar 31, 2026
@jp-launch-control
Copy link
Copy Markdown

jp-launch-control bot commented Mar 31, 2026

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

…dmin-notification-emailin-app-when-non-admin-is

# Conflicts:
#	projects/packages/jetpack-mu-wpcom/src/features/gutenberg-rtc-notices/gutenberg-rtc-notices.php
#	projects/packages/rtc/tests/php/RTC_Notices_Test.php
Create a reusable function library at jetpack-mu-wpcom/src/lib/ with
generic helpers for site owner resolution, admin notifications (bell +
email), and site slug resolution. These work on both Simple and
Atomic/WoW sites.

- lib/site-owner.php: wpcom_get_site_owner_id(), wpcom_is_site_owner()
- lib/admin-notifications.php: wpcom_send_bell_notification(),
  wpcom_send_email_notification(), wpcom_build_email_html()
- lib/site-slug.php: wpcom_get_site_slug() (guarded)
- lib/AGENTS.md: agent-first documentation for discovery
- Update RTC package to delegate to lib functions
- Add tests for all lib functions
@github-actions github-actions bot added the Docs label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs [mu wpcom Feature] Gutenberg Rtc Notices [Package] Jetpack mu wpcom WordPress.com Features [Package] Rtc [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