核心变更: - 数据库: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>
56 lines
2.1 KiB
Markdown
56 lines
2.1 KiB
Markdown
# Repository Guidelines
|
|
|
|
## Project Structure & Module Organization
|
|
|
|
- `outlook_web/`: Flask backend (`app.py`, `routes/`, `services/`, `repositories/`, `security/`).
|
|
- `static/` + `templates/`: frontend assets and HTML templates.
|
|
- `data/`: runtime data (SQLite DB default: `data/outlook_accounts.db`). Do not commit production data.
|
|
- `tests/`: unit/contract tests (CI runs `unittest` discovery).
|
|
- Top-level entrypoints: `web_outlook_app.py` (web app), plus utility scripts like `start.py` / `outlook_mail_reader.py`.
|
|
|
|
## Build, Test, and Development Commands
|
|
|
|
Local (Windows/macOS/Linux):
|
|
|
|
```bash
|
|
python -m venv .venv
|
|
# Windows: .\.venv\Scripts\activate
|
|
# macOS/Linux: source .venv/bin/activate
|
|
pip install -r requirements.txt
|
|
python web_outlook_app.py
|
|
```
|
|
|
|
Testing:
|
|
|
|
```bash
|
|
python -m unittest discover -s tests -v
|
|
```
|
|
|
|
Docker:
|
|
|
|
```bash
|
|
docker build -t outlook-email-plus .
|
|
docker run --rm -p 5000:5000 -v ./data:/app/data outlook-email-plus
|
|
```
|
|
|
|
## Coding Style & Naming Conventions
|
|
|
|
- Python: format with `black` (line length `127`) and sort imports with `isort` (profile `black`).
|
|
- Lint/type/security checks used in CI: `flake8` (incl. complexity), `mypy`, `bandit`.
|
|
- Naming: modules and functions use `snake_case`; classes use `PascalCase`; constants use `UPPER_SNAKE_CASE`.
|
|
|
|
## Testing Guidelines
|
|
|
|
- Prefer focused unit tests in `tests/test_*.py`; keep tests deterministic (avoid network calls unless explicitly mocked).
|
|
- Add/adjust tests when changing `outlook_web/` service logic or security-sensitive behavior (auth, token refresh, encryption).
|
|
|
|
## Commit & Pull Request Guidelines
|
|
|
|
- Commit messages follow a Conventional-Commits-like prefix: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:`, `ci:`, `style:`, `release:`.
|
|
- PRs should follow `.github/PULL_REQUEST_TEMPLATE.md`: include what changed, why, and screenshots for UI changes; link related issues when applicable.
|
|
|
|
## Security & Configuration Tips
|
|
|
|
- Configure via environment variables or `.env` (see `.env.example`). Always set a strong `SECRET_KEY`; never commit credentials or refresh tokens.
|
|
- If debugging locally, use sample data and keep secrets out of logs and screenshots.
|