68 Commits
Author SHA1 Message Date
胡绍康 d50f01663c feat: finalize pool registration flow and docs 2026-03-17 20:02:21 +08:00
胡绍康 6d95c74272 fix: align external pool POST and stats responses with external API contract 2026-03-17 10:40:14 +08:00
胡绍康 aa01758ad9 feat: add granular release controls and key-based access for external pool 2026-03-16 20:29:35 +08:00
胡绍康 431d6af233 feat: require explicit enablement for external pool endpoints via settings 2026-03-16 20:16:58 +08:00
胡绍康 b6bde5ea18 feat: add protected external pool API endpoints with API key guards and tests 2026-03-16 20:01:45 +08:00
胡绍康 0d92a613f5 feat: implement PRD-00009 MT-1 internal email pool with full P0 contract (claim/release/complete/stats, ownership checks, lease expiry, cooldown recovery, 38 pool tests) 2026-03-16 19:20:02 +08:00
胡绍康 9594cdd443 release: v1.7.0 2026-03-15 18:04:16 +08:00
胡绍康 cb4a119a47 release: v1.6.1 2026-03-15 12:57:01 +08:00
胡绍康 a26079026b fix: clear release quality gates 2026-03-15 09:41:45 +08:00
胡绍康andCopilot 1dec707ac3 release: v1.6.0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-13 12:47:21 +08:00
胡绍康andCopilot 6085ddd926 fix: harden external API guard client IP
Use auth.get_client_ip for whitelist/rate-limit decisions to avoid X-Forwarded-For spoofing. Add tests for trusted-proxy behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-13 12:42:12 +08:00
胡绍康 01d1dc0874 feat: implement external API security architecture (public mode, IP whitelist, rate limit)
- Add ExternalApiGuard for IP whitelisting, rate limiting, and public mode enforcement
- Update wait-message to support async mode
- Fix bugs in verification code extraction (BUG-00014 to BUG-00017)
- Update documentation and architectural diagrams
2026-03-13 11:27:34 +08:00
胡绍康andCopilot 09c3ab3416 fix: gate low-confidence verification extraction results as 404 (BUG-00017)
- Add code_confidence/link_confidence fine-grained fields to extractor
- Service-layer credibility gate: confidence != high -> nullify result -> 404
- Caller-directed extraction (code_regex only) gets high confidence
- Narrow LINK_CONTEXT_PHRASES with object nouns (email/account) prevent false positives
- 31 new tests (21 unit + 10 integration), 376 total passing
- Update docs/api.md with new fields, null semantics, v1.5 gating notes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-12 23:24:02 +08:00
胡绍康andCopilot 7128edeaaa feat: PRD-00008 P2 wait-message 异步探测解耦 — probe 缓存、后台轮询、333 测试全绿
- DB v6→v7:新增 external_probe_cache 表(状态/结果/过期时间)
- external_api.py:create_probe / get_probe_status / poll_pending_probes / cleanup
- wait-message 支持 mode=sync(P0 向下兼容)和 mode=async(P2 异步探测)
- 新增 GET /api/external/probe/<probe_id> 查询探测状态
- scheduler.py:注册 5 秒间隔的 external_probe_poll Job
- 新增 12 个 P2 测试(TC-PROBE-01~12),总计 333 测试全绿
- api.md:新增 probe 端点文档、更新 wait-message 双模式说明
- TODO-00008 P2 勾选完成

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 22:47:19 +08:00
胡绍康andCopilot a01b48a813 feat: PRD-00008 P1 公网模式安全层 — 守卫模块、设置 UI、321 测试全绿
- 新增 external_api_guard.py:IP 白名单、限流(SQLite 分钟桶)、高风险端点禁用
- DB v5→v6:新增 external_api_rate_limits 表 + 5 项 P1 默认设置
- 10 个外部 API 端点集成 @external_api_guards() 装饰器
- capabilities 端点增强:public_mode / restricted_features
- settings 控制器 + 前端 UI:公网模式开关、IP 白名单、限流、功能禁用
- 新增 18 个 P1 守卫测试(TC-GUARD-01~18),总计 321 测试全绿
- 更新 api.md:P1 错误码、配置文档
- 默认 public_mode=false,与 P0 行为完全兼容

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 22:18:40 +08:00
胡绍康andCopilot 085796eebe fix: PRD-00008 P0 审查修复 — OpenAPI schema 一致性、审计日志补全、测试覆盖 51→303
- fix(openapi): VerificationCodeData 补齐 verification_link/links/formatted 字段
- fix(openapi): confidence 枚举修正为 [high, low](无 medium)
- fix(openapi): AccountStatusData 补 status 字段
- fix(openapi): VerificationLinkData 补 email 属性
- fix(controllers): verification-code/link/wait-message 异常路径补审计日志
- test: 新增 30 条 P0 测试(auth、param、error、schema、regression)
- test: 新增 11 条 P1 extractor 边界测试(TC-EXT-01~04)
- docs: TODO-00008 更新至 V1.1(P0 已完成)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 17:57:37 +08:00
胡绍康 1d4d848702 fix: align external api behavior with PRD-00008 2026-03-10 21:24:55 +08:00
胡绍康 3ebf9172bf style: format external api changes for quality checks 2026-03-09 15:09:21 +08:00
胡绍康 9673b3524d feat: add external api docs tests and verification updates 2026-03-09 15:07:18 +08:00
胡绍康 8ee73e6572 style: apply latest black formatting for ci 2026-03-09 13:46:45 +08:00
胡绍康 48783387ac style: format tracked python files for ci 2026-03-09 13:42:00 +08:00
胡绍康 98febc798a fix: resolve copy logout and favicon regressions 2026-03-09 12:58:01 +08:00
胡绍康 8ad5832a1d release: v1.5.1 — Microsoft Refresh Token 滚动更新 2026-03-07 18:49:10 +08:00
胡绍康andClaude Opus 4.6 34f2125d51 feat: 实现 Microsoft Refresh Token 滚动更新机制
- 新增 test_refresh_token_with_rotation 函数支持返回新 refresh_token
- 在所有刷新场景(单账号/批量/定时任务)中自动保存滚动更新的 token
- 更新调度器、控制器、服务层以支持 token 轮换
- 补充测试用例验证 token 滚动更新逻辑
- 符合 Microsoft Learn 文档建议:每次使用时保存新的 refresh_token

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 16:08:57 +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 5ade471cef perf: IMAP 两步策略 — 先 INTERNALDATE 过滤再下载 RFC822
避免对游标之前的邮件下载完整正文,大幅减少 QQ 等大收件箱的获取时间
第一步:批量 FETCH INTERNALDATE 快速过滤
第二步:仅对候选邮件下载 RFC822 解析正文

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 19:18:06 +08:00
胡绍康andCopilot 9c838da1f3 perf: 并行获取所有账号邮件(ThreadPoolExecutor)
串行 5 账号耗时 ~145s → 并行后预计 ~30s
提取 _fetch_account_emails 独立函数用于并行
游标逻辑不变:成功推进、失败保留

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 19:09:29 +08:00
胡绍康andCopilot f2f3c62b57 fix: 调度器默认轮询间隔从 600s 改为 60s
默认值和注释均更新为 60 秒,与前端设置一致

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 19:05:39 +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 d4f8f609cf fix: IMAP timezone mismatch causing duplicate pushes (BUG-TG-006)
Root cause: parsedate_to_datetime preserves local timezone (e.g., +0800)
but strftime strips it, producing local time string (17:00) compared
against UTC cursor (09:00). Local > UTC → same email never filtered.

Fix: convert received_dt to UTC via astimezone(timezone.utc) before
formatting to ISO string for comparison.

Verified: job log changed from sent=1 (every run) to sent=0 (no new mail).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 17:21:36 +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 4adb255e87 fix: telegram push Graph API proxy support, client_id SELECT, and frontend null checks
- Fix _fetch_new_emails_graph to use get_access_token_graph (not get_access_token)
- Add client_id to get_telegram_push_accounts() SELECT
- JOIN groups table to get proxy_url per account
- Pass proxy_url to get_access_token_graph() and requests.get()
- Add null checks for Telegram DOM elements in loadSettings/saveSettings
- Add job start/end logging to run_telegram_push_job
- Add scheduler registration log message

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 16:16:49 +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
胡绍康andCopilot 450fc6dd45 release: v1.4.0 — 账号导入导出无缝迁移
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-04 20:38:07 +08:00
胡绍康andCopilot 973412d44c feat: 账号导入导出无缝迁移(PRD-00006/FD-00006)
- 新增 auto 智能混合导入模式:自动识别 Outlook/IMAP/GPTMail 行类型
- 域名推断 provider(gmail/qq/163/126/yahoo/aliyun/outlook)
- 自动按 provider 创建/复用分组
- 支持重复策略(skip/overwrite)和兜底 IMAP 设置
- 导出升级为 v2:头部元信息 + GPTMail 分段 + 时间戳文件名
- 前端导入模态框支持 auto 模式 UI 交互
- 新增 41 个单元测试(163 总测试全部通过)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-04 20:33:19 +08:00
胡绍康andClaude Opus 4.6 d9a6889bd8 style: 修复代码格式以通过 Black 检查
- 修复多行 SQL 查询字符串的格式
- 移除不必要的括号
- 统一代码风格以符合 Black 规范

修复的文件:
- outlook_web/controllers/accounts.py
- outlook_web/controllers/system.py
- outlook_web/db.py
- outlook_web/repositories/accounts.py
- outlook_web/repositories/groups.py
- outlook_web/services/refresh.py
- outlook_web/services/scheduler.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 13:42:26 +08:00
胡绍康andClaude Opus 4.6 f7a8817970 style: 使用 Black 和 isort 格式化代码
- 使用 Black 格式化 47 个 Python 文件
- 使用 isort 修复 import 排序
- 修复 Code Quality CI/CD 检查失败问题

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 13:12:16 +08:00
胡绍康andClaude Opus 4.6 3e800c6198 release: v1.3.0 — 多邮箱统一管理系统
新增功能:
- 支持 Gmail/QQ/163/126/Yahoo/阿里邮箱/自定义 IMAP
- IMAP 通用服务与提供商配置系统
- 验证码提取支持 IMAP 邮箱
- 前端动态表单与账号类型标识

修复:
- 数据库 Schema v2 → v3 安全升级
- 定时刷新任务只处理 Outlook 账号
- IMAP 邮箱禁止远程删除保护

测试:122 个测试全部通过

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 22:58:09 +08:00
胡绍康andClaude Opus 4.6 64d8a6c357 feat(multi-mailbox): 实现多邮箱统一管理功能(PRD-00005)
核心变更:
- 数据库:Schema v3,accounts 表新增 account_type/provider/imap_host/imap_port/imap_password 字段
- 后端:新增通用 IMAP 服务(imap_generic.py)与邮箱提供商配置(providers.py)
- 导入:支持 Outlook/QQ/163/Gmail/自定义 IMAP 多格式批量导入,兼容注释行与导出格式
- 导出:按邮箱类型分组导出,保留 provider 信息便于重新导入
- 邮件读取:IMAP 账号走通用 IMAP 服务,Outlook 保持原 Graph/XOAUTH2 链路
- 验证码提取:IMAP 账号通过 IMAP 获取邮件详情后提取
- 安全约束:IMAP 账号禁用远程删除,敏感字段(imap_password)加密存储
- 前端:新增邮箱类型下拉、自定义 IMAP 配置区、provider 标签显示
- 调度器:定时刷新仅处理 Outlook 账号(IMAP 无 OAuth token 刷新语义)
- 日志:配置 outlook_web 命名空间日志输出到 stderr

技术细节:
- 保持 Outlook 旧格式完全兼容(四段式:email----password----client_id----refresh_token)
- IMAP 账号使用空字符串占位 client_id/refresh_token(满足 DB NOT NULL 约束)
- 支持导出格式智能识别(5 段 custom、3 段 provider、2 段配合输入框)
- 前端 DOMPurify 未加载时回退为基本 HTML 过滤(CDN 不可达场景)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 22:54:39 +08:00
胡绍康andCopilot c70d2b97dd chore: 代码质量修复 + CI升级
- black 格式化 (1 file)
- isort 排序修复 (30 files, --profile black)
- 升级 actions/checkout v4 → v6 (全部 3 个 workflow)
- 添加 pyproject.toml (black/isort 配置)
- isort CI 命令添加 --profile black 参数
- 114 测试全部通过

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-01 21:52:44 +08:00
胡绍康 7c6a794dfa chore(release): v1.1.1 2026-02-28 20:21:49 +08:00
胡绍康 20aa93be22 chore(release): v1.1.0 2026-02-27 17:04:20 +08:00
胡绍康andClaude Opus 4.6 0eb36f5175 style: 运行 Black 格式化所有 Python 代码
- 格式化 66 个 Python 文件以符合 Black 代码风格
- 修复 GitHub Actions Code Quality 工作流失败问题

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 18:23:57 +08:00
胡绍康andClaude Opus 4.6 5af073caa8 fix: 修复 CSRF token 导入错误并豁免临时邮箱 API
- 在 csrf.py 添加模块级别 generate_csrf() 函数,解决 /api/csrf-token 端点导入错误
- 为临时邮箱 API 路由添加 CSRF 豁免,避免 Session 认证下的 CSRF token 缺失错误
- 重构 temp_emails.py 路由注册逻辑,支持统一应用 csrf_exempt 装饰器

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 17:56:45 +08:00
胡绍康andClaude Opus 4.6 2aca6d9954 fix: 修复安全问题和错误处理改进
P0 安全修复:
- 添加 IP 信任链验证,防止 X-Forwarded-For 伪造攻击
- 导出验证 token 增加 IP 和 User-Agent 绑定校验
- 改用请求头传递导出 token,避免 URL 泄露

P1 改进:
- 错误响应自动使用正确的 HTTP 状态码(400/500)
- 4xx 错误使用 WARNING 日志级别,5xx 使用 ERROR

P2 文档更新:
- 更新 CLAUDE.md 架构说明,体现 controllers 层
- 添加 TRUSTED_PROXIES 和 PROXY_FIX_ENABLED 配置说明
- 修正登录锁定时长为 5 分钟

P3 工程卫生:
- 清理乱码字符
- 删除意外创建的 nul 文件

测试修复:
- 更新测试以适应新的 HTTP 状态码行为
- 添加测试前清理登录限制记录的逻辑

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 16:11:33 +08:00
胡绍康andClaude Opus 4.6 828d31f949 refactor: 删除 legacy.py - 完成模块化迁移
- 所有 API 路由已迁移到 controllers 层
- 中间件已迁移到 middleware 模块
- 调度器已迁移到 services/scheduler.py
- 95 个测试全部通过

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 12:48:44 +08:00