24 Commits
Author SHA1 Message Date
胡绍康 d50f01663c feat: finalize pool registration flow and docs 2026-03-17 20:02:21 +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 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
胡绍康 9673b3524d feat: add external api docs tests and verification updates 2026-03-09 15:07:18 +08:00
胡绍康 98febc798a fix: resolve copy logout and favicon regressions 2026-03-09 12:58:01 +08:00
胡绍康 1f8e09b77e fix: 账号列窄宽度自动紧凑显示 2026-03-07 22:57:27 +08:00
胡绍康andCopilot a539c77236 fix: 静默刷新 + requestAnimationFrame 恢复滚动位置
forceRefresh 时不显示 loading(保持旧内容避免 scrollTop 重置)
用 requestAnimationFrame 确保 DOM 渲染后恢复滚动位置

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 19:55:19 +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 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 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 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 4df3d5fecd feat(accounts): add Outlook register button and auto-fill token
Add a '🔑 注册' button to account panel header; show only when a non-temp group selected; on successful OAuth exchange auto-open Add Account modal and pre-fill client_id + refresh_token.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-03 22:53:16 +08:00
胡绍康andClaude Opus 4.6 f36d84c1b1 feat: 在前端侧边栏添加 GitHub 仓库链接
- 在侧边栏底部添加 GitHub 图标按钮
- 点击后在新标签页打开项目仓库
- 添加蓝色主题样式,与界面风格统一
- 支持响应式设计,移动端适配

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:41:24 +08:00
胡绍康andClaude Opus 4.6 ba83ca3bf6 chore: 准备开源发布 - 只保留源代码
移除所有非源代码文件:
- 删除 docs/ 目录(所有内部文档)
- 删除 tests/ 目录(所有测试文件)
- 删除 .github/ 目录(CI/CD 配置)
- 删除 .kiro/ 目录(IDE 配置)
- 删除 CONTRIBUTING.md, SECURITY.md

更新项目文件:
- 重写 README.md,简洁清晰(从 1600+ 行压缩到 237 行)
- 更新 .gitignore,忽略所有非源代码文件
- 使用 ASCII art 展示界面布局
- 添加 Shields.io 徽章美化项目

保留的文件:
- 源代码:outlook_web/, static/, templates/
- 入口文件:web_outlook_app.py, start.py, outlook_mail_reader.py
- 配置文件:requirements.txt, Dockerfile, .dockerignore, .env.example
- 项目文档:README.md, LICENSE, .gitignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 21:11:55 +08:00
胡绍康andClaude Opus 4.6 39854520e6 chore: 准备开源发布 - 清理项目文件
- 更新 .gitignore,忽略所有文档和临时文件
- 删除迁移痕迹文件(AI提示词、PRD文档等)
- 更新 README.md,移除截图引用
- 只保留源代码用于开源发布

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 20:41:51 +08:00
胡绍康 20aa93be22 chore(release): v1.1.0 2026-02-27 17:04:20 +08:00
胡绍康andClaude Opus 4.6 0ab50db85f feat: 实现可调整布局系统
- 新增布局管理器支持拖拽调整面板宽度
- 新增状态管理器实现布局持久化
- 重构前端页面结构优化四栏式布局
- 新增 Jest 测试框架和完整测试用例
- 完善项目文档(PRD/FD/TDD/TODO/LOG)
- 清理 Python 缓存文件并更新 .gitignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 14:49:36 +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 66d9b9749b feat: 批量操作与自动化增强 - 全选/复制验证码/自动轮询
功能实现:
- 全选功能:跨分组保持选中状态,使用全局 Set 存储
- 验证码提取:支持 Graph API → IMAP 回退策略
- 自动轮询:新邮件通知、红点提示、连续错误自动停止

BUG 修复 (BUG-001 ~ BUG-008):
- Toast 通知位置移至右下角
- 切换分组时保持全选状态
- 添加批量删除邮箱功能
- 验证码提取支持 IMAP 回退
- 修复轮询开关类型不一致 (boolean vs string)
- 完善轮询通知内容与红点位置
- 轮询次数校验改为 0-100 (0 表示持续)
- 复制按钮添加加载状态与反馈

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 21:03:53 +08:00
胡绍康andClaude Opus 4.6 a9b3e4254f fix: 修复临时邮箱生成失败的BUG (BUG-00001)
【问题描述】
- 用户生成临时邮箱时返回笼统错误:生成临时邮箱失败,请稍后重试
- 错误码:LEGACY_ERROR,无法定位具体失败原因
- 可能原因:API Key未配置、网络问题、API服务不可用等

【修复内容】
1. 改进 gptmail_request 函数
   - 添加 API Key 配置检查
   - 区分 10+ 种错误类型(CONFIG_ERROR, AUTH_ERROR, TIMEOUT_ERROR等)
   - 返回结构化错误信息

2. 改进 generate_temp_email 函数
   - 返回值改为 (email_addr, error_msg) 元组
   - 保留详细错误信息

3. 改进 api_generate_temp_email 函数
   - 使用详细错误信息返回给前端
   - 添加日志记录

4. 更新前端错误提示
   - 显示详细的错误信息

5. 编写单元测试
   - 新增 11 个单元测试
   - 更新 2 个现有测试的 mock

【测试结果】
- 所有测试通过:51/51 ✅

【相关文档】
- BUG文档:docs/BUGS/BUG-00001-临时邮箱生成失败.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 20:52:27 +08:00
胡绍康andClaude Opus 4.6 14b1a7fa09 refactor: P1阶段优化 - 收敛全局变量与清理legacy代码
- 收敛前端全局变量:将 window.lastRefreshTime 和 window._lastFetchErrorDetails 改为模块变量
- 将内联 onclick 事件改为事件监听器,消除对全局变量的依赖
- 删除 legacy.py 中已被 re-export 覆盖的旧函数实现(settings 和 groups 相关,约140行)
- 所有测试通过(40/40)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 19:30:02 +08:00
胡绍康andClaude Opus 4.6 192240436d refactor: 模块化架构重构 & 完善测试与文档体系
- 架构重构:拆分为 routes/services/repositories/security 分层结构
- 新增测试:添加完整的单元测试套件(烟雾测试/核心功能/错误处理等)
- 完善文档:添加开发者指南、运行验证、回归清单、性能基线等文档
- 前后端分离:静态资源独立,模板组件化
- CI/CD:添加 GitHub Actions 自动化测试
- Docker 优化:添加健康检查,修复调度器启动问题
- 配置增强:支持 SCHEDULER_AUTOSTART 环境变量

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:54:16 +08:00