feat: add admin endpoint to send email announcements - #2236
Open
dragosp1011 wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
There are confirmed issues in the new announcement email template and security/behavior concerns in the recipient resolution and secret-checking logic that should be addressed before merging.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an opt-in wallet-backend admin endpoint to send email announcements, gated by ADMIN_NOTIFICATION_SECRET and x-admin-secret, with SendGrid batching support and Helm/env wiring so it can be enabled safely in deployed environments.
Changes:
- Introduces
/admin/notifications/email(only registered whenADMIN_NOTIFICATION_SECRETis set) with request validation forsendToAllvs explicitrecipients. - Implements
EmailService.sendAnnouncementBatch()using SendGrid personalizations with per-recipient fallback and failure reporting. - Adds controller/service unit tests and wires new configuration into
.env.exampleand the wallet Helm chart.
File summaries
| File | Description |
|---|---|
| packages/wallet/backend/tests/admin-notification/service.test.ts | Adds service-level tests for recipient resolution and SendGrid batch/fallback behavior. |
| packages/wallet/backend/tests/admin-notification/controller.test.ts | Adds controller + middleware tests, including “disabled when secret missing” behavior. |
| packages/wallet/backend/src/user/service.ts | Adds getVerifiedUserEmails() to support broadcasting to verified users. |
| packages/wallet/backend/src/middleware/isAdminSecret.ts | Adds admin-secret middleware to gate the endpoint. |
| packages/wallet/backend/src/email/templates/announcementEmail.ts | Adds HTML template for announcement emails. |
| packages/wallet/backend/src/email/service.ts | Adds batched announcement sending via SendGrid personalizations and fallback sending. |
| packages/wallet/backend/src/createContainer.ts | Conditionally registers the admin notification controller/service when enabled. |
| packages/wallet/backend/src/config/env.ts | Adds ADMIN_NOTIFICATION_SECRET env parsing/normalization. |
| packages/wallet/backend/src/app.ts | Wires the new admin route behind the middleware and env flag. |
| packages/wallet/backend/src/admin-notification/validation.ts | Adds request body validation schema and limits (e.g., max body length). |
| packages/wallet/backend/src/admin-notification/service.ts | Implements recipient resolution, validation, and send orchestration. |
| packages/wallet/backend/src/admin-notification/controller.ts | Adds controller handler that validates input and returns success responses. |
| packages/wallet/backend/.env.example | Documents the new env var used to enable the endpoint. |
| helm/testnet-wallet/values.yaml | Wires ADMIN_NOTIFICATION_SECRET as an optional secret-driven env var in Helm. |
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Context
Changes