feat: add RootEmailNotificationPlugin#1085
Open
stevenle wants to merge 2 commits into
Open
Conversation
Adds a notification service that sends email when CMS actions occur,
plus a standalone EmailClient for sending email from arbitrary
server-side code.
- New `RootEmailNotificationPlugin` factory at
`@blinkk/root-cms/email-notification`. Subscribes to `onAction()` via
the existing notification service hook.
- Recipients can be email addresses, role specifiers (e.g.
`'role:ADMINS'`), or functions; user-configurable filters
(`include`/`exclude` globs or a function) gate which actions trigger
email.
- Plain-text email templates with `{{var}}` interpolation, looked up
per-action and via prefix glob (e.g. `'tasks.*'`).
- New `EmailClient` at `@blinkk/root-cms/email-client` queues email
documents in Firestore for delivery by the existing root-services
Go worker. Adds cc/bcc/replyTo support to the worker.
- Tasks special case: for `tasks.*` actions, subscribers stored on the
task doc and `@<email>` mentions extracted from comments are
automatically notified.
- Adds `subscribers` field to `Task`, with subscribe/unsubscribe API
and UI controls in the task detail page; comment authors are
auto-subscribed.
https://claude.ai/code/session_01JSn1UwdSeg9oDqfgJ4yBup
Adds an opt-in plugin wrapper at docs/plugins/email-notifications.ts and wires it into docs/root.config.ts so the email notification plugin can be tested end-to-end on rootjs.dev. - The plugin is enabled when EMAIL_NOTIFICATIONS_FROM is set; otherwise the plugin is omitted so local dev keeps working without extra setup. - Recipients are configurable via EMAIL_NOTIFICATIONS_RECIPIENTS (comma-separated emails or role:NAME refs); defaults to role:ADMIN. - Includes templates for doc.publish, tasks.create, tasks.comment.add, and a tasks.* fallback so we can verify each path. - Adds a small dev script (scripts/test_email_notification.mjs) that triggers a synthetic action via RootCMSClient.logAction, useful to inspect the queued email doc in Firestore. https://claude.ai/code/session_01JSn1UwdSeg9oDqfgJ4yBup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a comprehensive email notification system for Root CMS, including a new
RootEmailNotificationPluginthat sends emails when CMS actions occur, along with task subscriber management features in the UI.Key Changes
Email Notification Plugin (
email-notification-plugin.ts)RootEmailNotificationPluginfactory that creates aCMSNotificationServicefor sending emails on CMS actionsrole:ADMIN,role:ADMINS)task:subscriberstasks.*){{action}},{{by}},{{metadata.*}}, etc.)EmailPreferencesdocsEmail Client (
email-client.ts)EmailClientclass for queuing emails to FirestoreProjects/<projectId>/Emailscollection withpendingstatusTask Subscriber Management
subscribersfield on Task documents (array of lowercase emails)subscribeToTask()andunsubscribeFromTask()functions for managing subscriptionsisUserSubscribedToTask()helper to check subscription statusextractMentions()function to parse@emailmentions from comments and rich textUI Components
TaskSubscribeButton: Inline button to toggle current user's subscriptionTaskSubscribersPanel: Sidebar panel showing subscriber list with add/remove functionalityEmail Worker Enhancement
Package Configuration
@blinkk/root-cms/email-clientand@blinkk/root-cms/email-notificationNotable Implementation Details
{{metadata.taskId}})*@example.com) are excluded from role-based recipientshttps://claude.ai/code/session_01JSn1UwdSeg9oDqfgJ4yBup