邮件消息数据类
| 38 | |
| 39 | @dataclass |
| 40 | class EmailMessage: |
| 41 | """邮件消息数据类""" |
| 42 | id: str # 消息 ID |
| 43 | subject: str # 主题 |
| 44 | sender: str # 发件人 |
| 45 | recipients: List[str] = field(default_factory=list) # 收件人列表 |
| 46 | body: str = "" # 正文内容 |
| 47 | body_preview: str = "" # 正文预览 |
| 48 | received_at: Optional[datetime] = None # 接收时间 |
| 49 | received_timestamp: int = 0 # 接收时间戳 |
| 50 | is_read: bool = False # 是否已读 |
| 51 | has_attachments: bool = False # 是否有附件 |
| 52 | raw_data: Optional[bytes] = None # 原始数据(用于调试) |
| 53 | |
| 54 | def to_dict(self) -> Dict[str, Any]: |
| 55 | """转换为字典""" |
| 56 | return { |
| 57 | "id": self.id, |
| 58 | "subject": self.subject, |
| 59 | "sender": self.sender, |
| 60 | "recipients": self.recipients, |
| 61 | "body": self.body, |
| 62 | "body_preview": self.body_preview, |
| 63 | "received_at": self.received_at.isoformat() if self.received_at else None, |
| 64 | "received_timestamp": self.received_timestamp, |
| 65 | "is_read": self.is_read, |
| 66 | "has_attachments": self.has_attachments, |
| 67 | } |
| 68 | |
| 69 | |
| 70 | @dataclass |
no outgoing calls
no test coverage detected