RTC: Send async admin notifications when non-admin is blocked by collaborator limit#47868
RTC: Send async admin notifications when non-admin is blocked by collaborator limit#47868
Conversation
…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
|
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: 🔴 Action required: Please add missing changelog entries for the following projects: Use the Jetpack CLI tool to generate changelog entries by running the following command: 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. |
…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
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:
notes_send_callback— appears in the WP.com notification bellwpcom_rtc_async_notification_interval)wpcom_rtc_get_plan_owner_id()from the existingwpcom_rtc_is_plan_owner()so the owner ID is reusableChanges
gutenberg-rtc-notices.php— newwpcom_rtc_get_plan_owner_id()function;wpcom_rtc_is_plan_owner()refactored to use itclass-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 withrecord_join_requestTest plan
notes_send_callback)wpcom_rtc_async_notification_intervalfilter worksjetpack docker phpunit -- --filter=RTC_Notices_Test🤖 Generated with Claude Code