Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SystemEmail

Overview

The SystemEmail class manages email template configuration and email delivery services across the platform. It provides template-based email management with approval workflows and AWS SES integration for email delivery.

General Purpose:

  • Email template management with dynamic content and approval workflows
  • Email delivery for member, program management, and system notifications
  • Template-based email system with parameter mapping and rendering capabilities
  • Template-based architecture using template IDs as instance identifiers
  • Integration with approval workflows for template changes and email operations

Data Structure

State Schema

interface SystemEmailState {
  private: {
    template: EmailTemplate
  }
  public: object
}

Enums and Types

enum SystemEmailEvents {
  SYSTEM_EMAIL_UPDATE = 'system_email_update',
  SYSTEM_EMAIL_STATUS_UPDATE = 'system_email_status_update'
}

enum SystemEmailType {
  MEMBER = 'member',
  PROGRAM_MANAGEMENT = 'program_management',
  SYSTEM = 'system'
}

enum SystemEmailStatus {
  ACTIVE = 'active',
  INACTIVE = 'inactive'
}

Additional Structures

interface EmailTemplate {
  type: SystemEmailType
  status: SystemEmailStatus
  to: string[]
  title: string
  subject: string
  json: string
  html: string
}

interface CreateSystemEmailInput {
  templateId: SystemEmailTemplateIds
  to?: string[]
  status: SystemEmailStatus
  subject: string
  html: string
  json: string
  title: string
  type: SystemEmailType
}

interface UpdateSystemEmailTemplateInput {
  to?: string[]
  subject: string
  html: string
  json: string
  title: string
}

interface SendSystemEmailInput {
  to?: string[]
  parameters: any
}

Core Functionality

Main Feature Groups

  • Template Management: Email template creation, modification, and lifecycle management with approval workflows
  • Email Delivery: Email sending with parameter mapping and dynamic content rendering using AWS SES
  • Approval Integration: Workflow-based approval system for template changes and email operations
  • Content Rendering: Template rendering with parameter substitution and dynamic content generation
  • Multi-Type Support: Support for member notifications, program management communications, and system alerts
  • Status Management: Template activation/deactivation with workflow integration for operational control

Workflow Integration

The SystemEmail class extends WorkflowCompatibleStateManager and integrates with the workflow system:

  • Status Transitions: Workflow rules manage template status changes between active and inactive states
  • Events: System email update and status update events trigger workflow processing
  • Approval Integration: Template modifications require approval through ApprovalManager integration
  • Business Rules: Configurable workflow rules control template lifecycle and operational constraints

API Methods

Template Management

  • updateSystemEmailTemplate (WRITE) - Update system email template

    • Modify existing email templates with approval workflow integration
    • Supports dynamic content updates and recipient list modifications
  • getSystemEmailTemplate (READ) - Get system email template

    • Retrieve specific email template details and configuration
  • listSystemEmailTemplates (READ) - Get all system email templates

    • Access complete template library with filtering and status information
  • getSystemEmailTemplateFields (READ) - Get system email template fields

    • Retrieve template field definitions and parameter mapping information

Email Operations

  • sendSystemEmail (QUEUED_WRITE) - Send system emails
    • Execute email delivery with parameter mapping and template rendering
    • Support for dynamic recipient lists and content personalization

Approval Operations

  • approve (QUEUED_WRITE) - Approve email template changes
    • Process approval workflows for template modifications and status changes

Key Features

  1. Architecture Pattern: Template-based instances with template IDs as instance identifiers for template-specific management
  2. Integration Points: Authorized for use by all classes but implementation not yet present in other classes
  3. Workflow Support: Full workflow integration for template approval and status management operations
  4. Security Features: Approval-based template modifications and role-based access control for email operations
  5. Data Management: Template-based state management with workflow-compatible state transitions
  6. External Integrations: AWS SES integration for email delivery with support for HTML and text content
  7. Performance Features: Template rendering with parameter mapping and dynamic content generation
  8. Audit/Logging: Complete tracking of template changes, email deliveries, and approval workflows

Class Relations

The following diagram illustrates how SystemEmail integrates with other system components:

SystemEmail Relations