Remove email outbox collection and process job; refactor email templates with rich text support and slug generation

This commit is contained in:
2025-09-13 12:11:35 +02:00
parent ed9d979d3e
commit 3868e74770
34 changed files with 2674 additions and 374 deletions

56
test-slug-system.js Normal file
View File

@@ -0,0 +1,56 @@
// Test script to verify slug-based template system
import { getPayload } from 'payload'
import configPromise from './dev/payload.config.js'
import { sendEmail } from './dist/utils/helpers.js'
async function testSlugSystem() {
console.log('🔄 Testing slug-based template system...\n')
try {
const config = await configPromise
const payload = await getPayload({ config })
console.log('📝 Sending email using template slug "welcome-email"')
const emailId = await sendEmail(payload, {
templateSlug: 'welcome-email',
to: 'test-slug@example.com',
variables: {
firstName: 'SlugTest',
siteName: 'Slug Demo Site',
createdAt: new Date().toISOString(),
isPremium: true,
dashboardUrl: 'http://localhost:3000/admin',
},
})
console.log('✅ Email queued successfully with ID:', emailId)
// Check if email was queued with templateSlug
const email = await payload.findByID({
collection: 'emails',
id: emailId,
})
console.log('\n📧 Email details:')
console.log('- ID:', email.id)
console.log('- To:', email.to)
console.log('- Subject:', email.subject)
console.log('- Template Slug:', email.templateSlug)
console.log('- Status:', email.status)
console.log('- Subject contains personalized data:', email.subject.includes('SlugTest'))
if (email.templateSlug === 'welcome-email') {
console.log('\n✅ Slug-based template system working correctly!')
} else {
console.log('\n❌ Template slug not stored correctly')
}
process.exit(0)
} catch (error) {
console.error('❌ Error:', error)
process.exit(1)
}
}
testSlugSystem()