# Path: src/schemas/messages.py
# class MessageStatus(str, Enum):
#     """
#     Combined MandrillMessageStatus and MessageBirdMessageStatus
# 
#     Should match MESSAGE_STATUSES sql enum
#     """
# 
#     render_failed = 'render_failed'
#     send_request_failed = 'send_request_failed'
# 
#     send = 'send'
#     deferral = 'deferral'
#     hard_bounce = 'hard_bounce'
#     soft_bounce = 'soft_bounce'
#     open = 'open'
#     click = 'click'
#     spam = 'spam'
#     unsub = 'unsub'
#     reject = 'reject'
# 
#     # used for sms
#     scheduled = 'scheduled'
#     # send = 'send'  # above
#     buffered = 'buffered'
#     delivered = 'delivered'
#     expired = 'expired'
#     delivery_failed = 'delivery_failed'
# 
# class SendMethod(str, Enum):
#     """
#     Should match SEND_METHODS sql enum
#     """
# 
#     email_mandrill = 'email-mandrill'
#     email_ses = 'email-ses'
#     email_test = 'email-test'
#     sms_messagebird = 'sms-messagebird'
#     sms_test = 'sms-test'


import json
from datetime import datetime
from markupsafe import Markup
from pydantic import UUID4, BaseModel, Json, PositiveInt
from typing import List, Optional
from src.schemas.messages import MessageStatus, SendMethod
        return {
            'id': self.id,
            'external_id': self.external_id,
            'to_ext_link': self.to_user_link,
            'to_address': self.to_address,
            'to_dst': f'{self.to_first_name or ""} {self.to_last_name or ""} <{self.to_address}>'.strip(' '),
            'to_name': f'{self.to_first_name or ""} {self.to_last_name or ""}',
            'send_ts': self.send_ts,
            'subject': self.subject if self.method.startswith('email') else self.body,
            'update_ts': self.update_ts,
            'status': self.get_status_display(),
            'method': self.method,
        }

    def get_attachments(self):
        if self.attachments:
            for a in self.attachments:
                name = None
                try:
                    doc_id, name = a.split('::')
                    doc_id = int(doc_id)
                except ValueError:
                    yield '#', name or a
                else:
                    yield f'/attachment-doc/{doc_id}/', name


class Event(BaseModel):
    id: Optional[PositiveInt]
    message_id: Optional[PositiveInt]

# Path: src/schemas/messages.py
# class MessageStatus(str, Enum):
#     """
#     Combined MandrillMessageStatus and MessageBirdMessageStatus
# 
#     Should match MESSAGE_STATUSES sql enum
#     """
# 
#     render_failed = 'render_failed'
#     send_request_failed = 'send_request_failed'
# 
#     send = 'send'
#     deferral = 'deferral'
#     hard_bounce = 'hard_bounce'
#     soft_bounce = 'soft_bounce'
#     open = 'open'
#     click = 'click'
#     spam = 'spam'
#     unsub = 'unsub'
#     reject = 'reject'
# 
#     # used for sms
#     scheduled = 'scheduled'
#     # send = 'send'  # above
#     buffered = 'buffered'
#     delivered = 'delivered'
#     expired = 'expired'
#     delivery_failed = 'delivery_failed'
# 
# class SendMethod(str, Enum):
#     """
#     Should match SEND_METHODS sql enum
#     """
# 
#     email_mandrill = 'email-mandrill'
#     email_ses = 'email-ses'
#     email_test = 'email-test'
#     sms_messagebird = 'sms-messagebird'
#     sms_test = 'sms-test'


# Path: src/schemas/models.py
import json
from datetime import datetime
from markupsafe import Markup
from pydantic import UUID4, BaseModel, Json, PositiveInt
from typing import List, Optional
from src.schemas.messages import MessageStatus, SendMethod

        return {
            'id': self.id,
            'external_id': self.external_id,
            'to_ext_link': self.to_user_link,
            'to_address': self.to_address,
            'to_dst': f'{self.to_first_name or ""} {self.to_last_name or ""} <{self.to_address}>'.strip(' '),
            'to_name': f'{self.to_first_name or ""} {self.to_last_name or ""}',
            'send_ts': self.send_ts,
            'subject': self.subject if self.method.startswith('email') else self.body,
            'update_ts': self.update_ts,
            'status': self.get_status_display(),
            'method': self.method,
        }

    def get_attachments(self):
        if self.attachments:
            for a in self.attachments:
                name = None
                try:
                    doc_id, name = a.split('::')
                    doc_id = int(doc_id)
                except ValueError:
                    yield '#', name or a
                else:
                    yield f'/attachment-doc/{doc_id}/', name


class Event(BaseModel):
    id: Optional[PositiveInt]
    message_id: Optional[PositiveInt]

    status: Optional[MessageStatus]