10 Commits
Author SHA1 Message Date
胡绍康 48783387ac style: format tracked python files for ci 2026-03-09 13:42:00 +08:00
XiaoSihui c9e14231b1 release: v1.5.0 — Telegram 实时推送与去重稳定性优化 2026-03-06 23:00:59 +08:00
胡绍康andCopilot 71b5cc0293 feat: BUG-00011 P2 Message-ID 去重防止重复推送
- 新增 telegram_push_log 表 (schema v5),UNIQUE(account_id, message_id)
- IMAP fetch 提取 Message-ID header; Graph fetch 提取 internetMessageId
- 推送前查 push_log 跳过已推送邮件,推送后记录
- 每次 Job 结束清理 >7 天的去重记录
- 新增 4 个 TestMessageIdDedup 测试 + 更新 _make_email 含 message_id
- 228 tests passing (游标防重 + Message-ID 去重双保险)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 22:34:16 +08:00
胡绍康andCopilot d6af769401 fix: BUG-00011 游标竞态导致单封邮件重复推送
- cursor 从固定 job_start_time 改为 max(job_start_time, max_received_at)
- 防止邮件服务器时钟偏差 / fetch 窗口期间到达的邮件被重复拉取
- 新增 3 个 TestCursorClockSkew 测试 (时钟偏差 + 端到端防重)
- 224 tests passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 22:03:03 +08:00
胡绍康andCopilot 308494dcc9 feat: add PUSH_RECENCY_HOURS (12h) and TELEGRAM_PUSH_DELAY_SEC (1.5s)
- Skip emails older than 12 hours to prevent flooding on re-enable
- Add 1.5s delay between Telegram sends to avoid rate limiting
- Update tests T-19/T-20/T-22 to use recent timestamps and mock delay
- Add 2 new recency filter tests (old email skipped, recent passes)
- 221 tests passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 20:56:37 +08:00
胡绍康andCopilot c0381f6bf5 test: BUG-00010 新增 8 个测试(并行获取 + 游标策略 + 调度器默认值)
TestFetchAccountEmails: 4 个(首次运行/成功/失败/Outlook vs IMAP)
TestParallelJobBehavior: 4 个(发送失败计数/混合成功失败/全量处理/默认间隔)
总计 50 个 Telegram 测试 + 169 个现有 = 219 全部通过

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 20:33:48 +08:00
胡绍康andCopilot 2d14bbdc95 fix: BUG-00009 滚动位置保留 + 游标仅成功时推进 + 发送日志
D-1: loadAccountsByGroup forceRefresh 时保存/恢复 scrollTop
D-2: 移除 finally 块游标推进,仅 fetch 成功后更新游标
     _send_telegram_message 增加 HTTP 失败详情日志
     run_telegram_push_job 增加 per-account found 计数日志
T-21: 更新为验证异常时游标不推进
新增 8 个 BUG-00009 测试用例(时区转换 + 游标过滤 + 手动验证清单)
全量 211 测试通过

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 18:11:53 +08:00
胡绍康andCopilot 7f2f739c00 fix: widen poll interval range 10-86400s + add BUG-00008 analysis doc
D-3: Relax telegram poll interval constraints:
- Backend: 60-3600 → 10-86400 seconds
- Frontend: min/max attributes updated
- Scheduler: floor changed from 60 to 10 seconds
- Test T-29: adjusted boundary value (30→5)

BUG-00008: Comprehensive analysis comparing our implementation with
MailAggregator_Pro, covering cursor reset, tag UI, and interval limits.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 16:56:23 +08:00
胡绍康andCopilot 9085f99ed3 fix: reset push cursor on re-enable + add push tag UI
- toggle_telegram_push: reset cursor to NOW when transitioning 0→1
  (idempotent when already enabled, prevents historical email flood)
- Add '🔔 推送' tag to account cards when push is enabled
- Tag is clickable to disable push (removes tag)
- Add .tg-push-tag CSS (Telegram blue #0088cc)
- Add test T-12b: verify re-enable resets cursor
- Update BUG-00007 doc with BUG-TG-005

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 16:42:27 +08:00
胡绍康andCopilot 2326410067 feat: Telegram 实时推送功能(TODO-00007)
P0 核心功能:
- DB Schema v3→v4:accounts 表新增 telegram_push_enabled、telegram_last_checked_at 列
- Repository:toggle_telegram_push、update_telegram_cursor、get_telegram_push_accounts
- Service:telegram_push.py — Graph/IMAP 新邮件抓取 + Telegram Bot API 推送
- Scheduler:telegram_push_job 定时轮询(默认 600s,可配置 60-3600s)
- Controller/Route:POST /api/accounts/<id>/telegram-toggle、settings GET/PUT 扩展
- Frontend:账号卡片🔔推送开关、设置页 Telegram 配置区

P1 增强功能:
- POST /api/settings/telegram-test 发送测试消息端点
- 保存 telegram_poll_interval 时动态重调度(无需重启)
- accounts API 返回 telegram_push_enabled 字段

测试:33 项 Telegram 推送测试全部通过,202 项总测试零回归

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 09:23:04 +08:00