fix: reduce long-poll timeout to 2s, make mark_as_seen async to unblock TG sender
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import re
|
||||
import threading
|
||||
from typing import Generator, Optional
|
||||
from src.config import Config
|
||||
from src.email_client import fetch_unseen_emails, mark_as_seen, Email
|
||||
@@ -100,6 +101,11 @@ def tg_send_and_mark(cfg: Config, info: dict):
|
||||
original_recipient=info.get("original_recipient", ""),
|
||||
original_reply_to=info.get("original_reply_to", ""),
|
||||
account_email=info.get("account_email", ""))
|
||||
# 只有发送成功才标记已读
|
||||
mark_as_seen(acct, [(info["uid"], info.get("folder", "INBOX"))])
|
||||
logger.info(f" TG 发送成功,已标记已读")
|
||||
# 标记已读放到后台线程,不阻塞 TG 发送
|
||||
def _bg_mark():
|
||||
try:
|
||||
mark_as_seen(acct, [(info["uid"], info.get("folder", "INBOX"))])
|
||||
except Exception:
|
||||
pass
|
||||
threading.Thread(target=_bg_mark, daemon=True).start()
|
||||
logger.info(f" TG 发送成功,标记已读已提交后台")
|
||||
|
||||
Reference in New Issue
Block a user