-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Added email suppression adapter support with Mailgun implementation #25253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Added email suppression adapter support with Mailgun implementation #25253
Conversation
ref TryGhost#22771 This establishes the foundation for multi-provider email support using Ghost's existing AdapterManager pattern. The EmailProviderBase class defines the contract that all email provider adapters must follow, enabling community-developed providers to be published as npm packages. - Created EmailProviderBase with required send() method - Registered email adapter type in AdapterManager - Added comprehensive tests validating base class contract
|
Warning Rate limit exceeded@danielraffel has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 37 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (24)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Moved require('@tryghost/errors') to top of EmailProviderBase
- Removed duplicate @returns JSDoc tag
- Updated AdapterManager JSDoc to include 'email' adapter type
- Renamed test suite from 'integration with AdapterManager' to 'module exports'
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Fixed proactively based on PR1/PR2 feedback patterns: Code quality improvement:
All changes pushed in commit 4a4df96. |
ref TryGhost#21684 Implements Mailgun as an email provider adapter to work with Ghost's AdapterManager system. This enables future extensibility for other email providers (SendGrid, SES, Postmark) while maintaining full backward compatibility with existing Mailgun functionality. Key changes: - Created Mailgun adapter at adapters/email/mailgun/index.js extending EmailProviderBase - Removed legacy MailgunEmailProvider from services/email-service/ (single source of truth) - Enhanced AdapterManager to support runtime config injection for dependency injection - Added resetCacheFor() method to AdapterManager for proper encapsulation - Added safeguard to resetCacheFor() that throws for unknown adapter types (matches getAdapter pattern) - Fixed caching to clear cache when runtime config provided (prevents stale dependencies) - Updated EmailServiceWrapper to use adapter pattern - Added email adapter default configuration (defaults to Mailgun) - Comprehensive test coverage: 23 adapter tests + 2 resetCacheFor tests (all passing) Technical notes: - Adapter file must be index.js for Node.js module resolution (email/mailgun → email/mailgun/index.js) - Runtime config uses resetCacheFor() to maintain encapsulation vs direct instanceCache access - resetCacheFor() throws NotFoundError for unknown types to catch bugs early (consistent with getAdapter) - Maintains all existing Mailgun features: batch sending, recipient variables, delivery scheduling, error handling
- Use replaceAll() for global token replacement - Add guards for undefined replacements and replacement definitions - Default options parameter and destructure recipients/replacementDefinitions - Redact PII from error details (limit to 2000 chars) - Add defensive check for response.id - Wrap error handler in try-catch for safety - Remove redundant logging.info() call - Add mailgunClient interface validation in constructor
ref TryGhost#21684 Implements email analytics as an adapter to work with Ghost's AdapterManager system. This enables future extensibility for other email analytics providers while maintaining full backward compatibility with existing Mailgun analytics. Key changes: - Created EmailAnalyticsBase at adapters/email-analytics/EmailAnalyticsBase.js - Registered 'email-analytics' adapter type with AdapterManager - Implemented Mailgun analytics adapter at adapters/email-analytics/mailgun/index.js - Removed legacy EmailAnalyticsProviderMailgun from services/email-analytics/ - Updated EmailAnalyticsServiceWrapper to use adapter pattern - Enhanced AdapterManager to support runtime config injection - Added email-analytics adapter default configuration (defaults to Mailgun) - Comprehensive test coverage with 24 passing tests (7 base + 17 Mailgun) Technical notes: - Adapter file must be index.js for Node.js module resolution - Runtime config (config, settings) injected via AdapterManager - Maintains all existing Mailgun analytics features: event fetching, pagination, custom tags - fetchLatest() interface supports batch processing of email events (delivered, opened, failed, etc.)
- Moved require('@tryghost/errors') to top of mailgun adapter
- Added optional chaining for options.begin, options.end, options.maxEvents
- Added test case for undefined options parameter
- Created EmailSuppressionBase adapter base class with immutable requiredFns - Implemented Mailgun email suppression adapter extending base class - Registered email-suppression adapter type in AdapterManager - Added runtime config injection support with cache clearing to AdapterManager - Added resetCacheFor() method to AdapterManager for type-specific cache clearing - Updated email-suppression-list service to use adapter pattern - Removed legacy MailgunEmailSuppressionList implementation - Added comprehensive test coverage (12 base + 20 Mailgun = 32 tests) - Included EmailProviderBase and EmailAnalyticsBase for complete adapter support - Added default configs for email, email-analytics, and email-suppression adapters The adapter manages bounce and spam complaint suppression lists through Mailgun's API, supporting getSuppressionData, getBulkSuppressionData, and removeEmail operations. Cache clearing prevents stale dependency bugs when runtime config is provided.
- Moved require('@tryghost/errors') to top of mailgun adapter
4a4df96 to
54f51ab
Compare
Context
Final PR in 4-PR series to extract email functionality into adapters (#22771).
Series: #25250 → #25251 → #25252 → PR4 ✓
Changes
Creates EmailSuppressionBase adapter and implements Mailgun suppression list management using the adapter pattern.
The adapter manages bounce and spam complaint lists with support for checking suppression status (single/bulk) and removing entries from both Mailgun API and local database.
This completes the adapter foundation, making it straightforward to add alternative email providers like SendGrid, SES, or Postmark.
Removes legacy suppression list implementation in favor of adapter.
Series complete. All email functionality now uses adapter pattern.