feat: show full recipient and CC in email summary - Email class: add cc field - fetch_unseen_emails: parse Cc header - _format_normal: display full recipient, add CC line if present - send_summary/ai_process: pass cc through to email_context - save_email_context: store cc for callback use

This commit is contained in:
2026-07-18 20:07:21 +08:00
parent 7a01b29655
commit beaa3f146e
3 changed files with 22 additions and 5 deletions

View File

@@ -21,10 +21,14 @@ _ai_pool = ThreadPoolExecutor(max_workers=3, thread_name_prefix="ai_regen")
def send_summary(bot_token: str, chat_id: str, summary_text: str,
summary_data: dict, original_body: str, account_idx: int,
original_sender: str = "", original_recipient: str = "",
original_reply_to: str = "", account_email: str = "") -> int:
original_reply_to: str = "", account_email: str = "",
original_cc: str = "") -> int:
can_reply = summary_data.get("can_reply", True)
is_promotion = summary_data.get("category") == "promotion"
links = summary_data.get("links", [])
# summary_data 里可能有 cc
if original_cc:
summary_data["cc"] = original_cc
result = _tg_req(bot_token, "sendMessage", {
"chat_id": chat_id,
"text": summary_text,
@@ -38,11 +42,13 @@ def send_summary(bot_token: str, chat_id: str, summary_text: str,
"original_body": original_body,
"original_sender": original_sender or summary_data.get("sender", ""),
"original_recipient": original_recipient or summary_data.get("recipient", ""),
"original_cc": original_cc,
"original_reply_to": original_reply_to,
"account_idx": account_idx,
"account_email": account_email,
"sender": summary_data.get("sender", ""),
"subject": summary_data.get("subject", ""),
"cc": original_cc,
"can_reply": can_reply,
})
return msg_id
@@ -146,15 +152,21 @@ def _format_verification(data: dict, account_email: str = "") -> str:
def _format_normal(data: dict, account_email: str = "") -> str:
recipient = data.get("recipient", "未知")
cc = data.get("cc", "")
lines = [
f"📧 *{_escape(data.get('subject', '邮件摘要'))}*",
f"━━━━━━━━━━━━━━━━━━",
f"*收件账户:* {_escape(account_email)}",
f"*收件人:* {_escape(data.get('recipient', '未知'))}",
f"*收件人:* {_escape(recipient)}",
]
if cc:
lines.append(f"*抄送:* {_escape(cc)}")
lines.extend([
f"*发件人:* {_escape(data.get('sender', '未知'))}",
"",
_escape(data.get("summary", "")),
]
])
return "\n".join(lines)