From e0c2110c0967d6568c3a516b071102161a847e83 Mon Sep 17 00:00:00 2001 From: Zichao Lin Date: Wed, 22 Jul 2026 13:28:36 +0800 Subject: [PATCH] fix: use original email subject for reply, not AI-extracted title Reply emails should use the original subject from IMAP header (e.g. 'Re: [original]'), not the AI-generated Chinese summary title. --- src/summarizer.py | 2 ++ src/tg_bot.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/summarizer.py b/src/summarizer.py index e705210..a2cda3b 100644 --- a/src/summarizer.py +++ b/src/summarizer.py @@ -60,6 +60,7 @@ def ai_process(cfg: Config, user: UserConfig, acct_idx: int, mail: Email, tg_msg "original_recipient": mail.recipient, "original_reply_to": mail.reply_to, "original_cc": mail.cc, + "original_subject": mail.subject, "acct_idx": acct_idx, "account_email": mail.account_email, "uid": mail.uid, @@ -89,6 +90,7 @@ def tg_send_and_mark(cfg: Config, user: UserConfig, info: dict): "original_recipient": info.get("original_recipient", ""), "original_cc": info.get("original_cc", ""), "original_reply_to": info.get("original_reply_to", ""), + "original_subject": info.get("original_subject", ""), "account_email": info.get("account_email", ""), "account_idx": info["acct_idx"], "sender": info["data"].get("sender", ""), diff --git a/src/tg_bot.py b/src/tg_bot.py index f98fee9..c8a124a 100644 --- a/src/tg_bot.py +++ b/src/tg_bot.py @@ -360,7 +360,7 @@ def _handle_callback(bot_token: str, cfg: Config, cb: dict): action = parts[0] ctx = load_email_context(msg_id) - subject = ctx["subject"] if ctx else "?" + subject = ctx.get("original_subject") or ctx["subject"] if ctx else "?" logger.info("TG 回调: action=%s msg_id=%d subject=%s", action, msg_id, subject) if action == CALLBACK_VIEW_ORIG and ctx: @@ -725,7 +725,7 @@ def _do_send_reply(bot_token: str, cfg: Config, to_addr = parseaddr(ctx["sender"])[1] if not to_addr: to_addr = ctx["sender"] - subject = ctx["subject"] + subject = ctx.get("original_subject") or ctx["subject"] # 下载 Telegram 附件到本地 local_files = []