mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 00:03:23 +00:00
BREAKING CHANGE: Remove sendEmailWorkflow, add immediate processing to sendEmailTask
- Remove entire workflows directory and sendEmailWorkflow - Factor out email processing logic into reusable utilities (emailProcessor.ts) - Add processImmediately option to sendEmailTask input schema - Update sendEmailTask to process emails immediately when requested - Update processEmailsTask to use shared processing utilities - Remove workflow-related exports and plugin configuration - Simplify documentation to focus on unified task approach - Export new email processing utilities (processEmailById, processAllEmails) - Bump version to 0.4.0 (breaking change - workflows removed) Migration: Use sendEmailTask with processImmediately: true instead of sendEmailWorkflow
This commit is contained in:
36
README.md
36
README.md
@@ -382,16 +382,7 @@ await retryFailedEmails(payload)
|
||||
|
||||
## PayloadCMS Integration
|
||||
|
||||
The plugin provides both tasks and workflows for email processing:
|
||||
|
||||
### Tasks vs Workflows
|
||||
|
||||
- **Tasks**: Simple job execution, good for background processing
|
||||
- **Workflows**: More advanced with UI, status tracking, and immediate processing options
|
||||
|
||||
### Task Integration
|
||||
|
||||
The plugin provides a ready-to-use PayloadCMS task for queuing template emails:
|
||||
The plugin provides PayloadCMS tasks for email processing:
|
||||
|
||||
### 1. Add the task to your Payload config
|
||||
|
||||
@@ -464,25 +455,13 @@ The task can also be triggered from the Payload admin panel with a user-friendly
|
||||
- ✅ **Error Handling**: Comprehensive error reporting
|
||||
- ✅ **Queue Management**: Leverage Payload's job queue system
|
||||
|
||||
### Workflow Integration
|
||||
### Immediate Processing
|
||||
|
||||
For advanced features, use the workflow instead:
|
||||
The send email task now supports immediate processing. Enable the `processImmediately` option to send emails instantly:
|
||||
|
||||
```typescript
|
||||
import { sendEmailWorkflow } from '@xtr-dev/payload-mailing'
|
||||
|
||||
export default buildConfig({
|
||||
jobs: {
|
||||
workflows: [sendEmailWorkflow]
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**Key advantage**: Optional `processImmediately` option to send emails instantly instead of queuing.
|
||||
|
||||
```typescript
|
||||
await payload.workflows.queue({
|
||||
workflow: 'send-email',
|
||||
await payload.jobs.queue({
|
||||
task: 'send-email',
|
||||
input: {
|
||||
processImmediately: true, // Send immediately (default: false)
|
||||
templateSlug: 'welcome-email',
|
||||
@@ -492,6 +471,11 @@ await payload.workflows.queue({
|
||||
})
|
||||
```
|
||||
|
||||
**Benefits**:
|
||||
- No separate workflow needed
|
||||
- Unified task interface
|
||||
- Optional immediate processing when needed
|
||||
|
||||
## Job Processing
|
||||
|
||||
The plugin automatically adds a unified email processing job to PayloadCMS:
|
||||
|
||||
Reference in New Issue
Block a user