核心变更: - 数据库: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>
133 lines
3.9 KiB
Python
133 lines
3.9 KiB
Python
from __future__ import annotations
|
||
|
||
from flask import Blueprint
|
||
|
||
from outlook_web.controllers import accounts as accounts_controller
|
||
|
||
|
||
def create_blueprint() -> Blueprint:
|
||
bp = Blueprint("accounts", __name__)
|
||
|
||
# 基础 CRUD(已迁移到 controllers)
|
||
bp.add_url_rule(
|
||
"/api/accounts", view_func=accounts_controller.api_get_accounts, methods=["GET"]
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts", view_func=accounts_controller.api_add_account, methods=["POST"]
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/providers",
|
||
view_func=accounts_controller.api_get_providers,
|
||
methods=["GET"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/<int:account_id>",
|
||
view_func=accounts_controller.api_get_account,
|
||
methods=["GET"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/<int:account_id>",
|
||
view_func=accounts_controller.api_update_account,
|
||
methods=["PUT"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/<int:account_id>",
|
||
view_func=accounts_controller.api_delete_account,
|
||
methods=["DELETE"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/email/<email_addr>",
|
||
view_func=accounts_controller.api_delete_account_by_email,
|
||
methods=["DELETE"],
|
||
)
|
||
|
||
# 批量操作(已迁移到 controllers)
|
||
bp.add_url_rule(
|
||
"/api/accounts/search",
|
||
view_func=accounts_controller.api_search_accounts,
|
||
methods=["GET"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/batch-update-group",
|
||
view_func=accounts_controller.api_batch_update_account_group,
|
||
methods=["POST"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/batch-delete",
|
||
view_func=accounts_controller.api_batch_delete_accounts,
|
||
methods=["POST"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/tags",
|
||
view_func=accounts_controller.api_batch_manage_tags,
|
||
methods=["POST"],
|
||
)
|
||
|
||
# 导出功能(已迁移到 controllers)
|
||
bp.add_url_rule(
|
||
"/api/accounts/export",
|
||
view_func=accounts_controller.api_export_all_accounts,
|
||
methods=["GET"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/export-selected",
|
||
view_func=accounts_controller.api_export_selected_accounts,
|
||
methods=["POST"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/export/verify",
|
||
view_func=accounts_controller.api_generate_export_verify_token,
|
||
methods=["POST"],
|
||
)
|
||
|
||
# Token 刷新(已迁移到 controllers)
|
||
bp.add_url_rule(
|
||
"/api/accounts/<int:account_id>/refresh",
|
||
view_func=accounts_controller.api_refresh_account,
|
||
methods=["POST"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/refresh-all",
|
||
view_func=accounts_controller.api_refresh_all_accounts,
|
||
methods=["GET"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/<int:account_id>/retry-refresh",
|
||
view_func=accounts_controller.api_retry_refresh_account,
|
||
methods=["POST"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/refresh-failed",
|
||
view_func=accounts_controller.api_refresh_failed_accounts,
|
||
methods=["POST"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/trigger-scheduled-refresh",
|
||
view_func=accounts_controller.api_trigger_scheduled_refresh,
|
||
methods=["GET"],
|
||
)
|
||
|
||
# 刷新日志(已迁移到 controllers)
|
||
bp.add_url_rule(
|
||
"/api/accounts/refresh-logs",
|
||
view_func=accounts_controller.api_get_refresh_logs,
|
||
methods=["GET"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/<int:account_id>/refresh-logs",
|
||
view_func=accounts_controller.api_get_account_refresh_logs,
|
||
methods=["GET"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/refresh-logs/failed",
|
||
view_func=accounts_controller.api_get_failed_refresh_logs,
|
||
methods=["GET"],
|
||
)
|
||
bp.add_url_rule(
|
||
"/api/accounts/refresh-stats",
|
||
view_func=accounts_controller.api_get_refresh_stats,
|
||
methods=["GET"],
|
||
)
|
||
|
||
return bp
|