test
This commit is contained in:
@@ -112,6 +112,19 @@ class MailStore:
|
|||||||
|
|
||||||
logging.info(f"提取完成x3: 纯文本={len(body_text)}字节, HTML={len(body_html)}字节, 附件数={len(attachments)}")
|
logging.info(f"提取完成x3: 纯文本={len(body_text)}字节, HTML={len(body_html)}字节, 附件数={len(attachments)}")
|
||||||
|
|
||||||
|
# 创建邮件记录前的检查
|
||||||
|
if sender is None:
|
||||||
|
logging.error("发件人无效,无法保存邮件")
|
||||||
|
return False, "发件人无效"
|
||||||
|
|
||||||
|
if not recipients or isinstance(recipients, str) and not recipients.strip():
|
||||||
|
logging.error("收件人无效,无法保存邮件")
|
||||||
|
return False, "收件人无效"
|
||||||
|
|
||||||
|
# 处理邮件主题
|
||||||
|
if email_subject is None:
|
||||||
|
email_subject = "无主题" # 或者使用其他默认值
|
||||||
|
|
||||||
# 保存到数据库
|
# 保存到数据库
|
||||||
session = self.db_session_factory()
|
session = self.db_session_factory()
|
||||||
try:
|
try:
|
||||||
@@ -181,7 +194,7 @@ class MailStore:
|
|||||||
|
|
||||||
# 创建邮件记录
|
# 创建邮件记录
|
||||||
email_obj = Email(
|
email_obj = Email(
|
||||||
mailbox_id=mailbox_id, # 确保始终有邮箱ID
|
mailbox_id=mailbox_id,
|
||||||
sender=sender,
|
sender=sender,
|
||||||
recipients=str(recipients),
|
recipients=str(recipients),
|
||||||
subject=email_subject,
|
subject=email_subject,
|
||||||
|
|||||||
Reference in New Issue
Block a user