本次提交包含多项核心更新: 1. 新增微信4.0浅色主题UI模板资源与说明文档,补充了联系人图标、新的朋友入口等四个UI元素的图像匹配模板 2. 重构UI驱动层,将原2375行的单文件拆分为5个职责清晰的子驱动类,提升代码可维护性 3. 新增批量群发消息与聊天记录导出的完整数据模型、路由与后台协程,支持幂等校验与风控配置 4. 为所有业务接口新增post_verify校验逻辑,补充了verified字段返回操作结果 5. 优化媒体文件解密逻辑,修复了导出功能中的数据库错误处理与分辨率硬编码问题 6. 更新版本配置,将媒体发送功能标记为已落地,调整了能力列表与配置项
60 lines
2.5 KiB
Python
60 lines
2.5 KiB
Python
"""聊天记录导出相关数据模型。"""
|
||
from __future__ import annotations
|
||
|
||
from typing import Literal, Optional
|
||
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 导出请求(POST /api/messages/export 异步用)
|
||
# ---------------------------------------------------------------------------
|
||
class ExportRequest(BaseModel):
|
||
"""导出请求(POST /api/messages/export 异步用)。
|
||
|
||
limit > 1000 或 include_media=true 时应走异步端点;
|
||
同步 GET /api/messages/export 仅服务 limit ≤ 1000 的纯文本导出。
|
||
"""
|
||
|
||
talker: str = Field(..., description="会话 wxid 或群 id")
|
||
format: Literal["html", "csv", "json", "txt"] = Field(
|
||
"html", description="导出格式:html / csv / json / txt"
|
||
)
|
||
limit: int = Field(1000, ge=1, le=100000, description="导出消息数上限")
|
||
include_media: bool = Field(False, description="是否打包媒体文件(zip)")
|
||
media_inline: bool = Field(
|
||
False, description="媒体是否内联(仅 HTML,将图片 base64 嵌入)"
|
||
)
|
||
start_time: Optional[int] = Field(None, description="起始时间戳(Unix 秒,含)")
|
||
end_time: Optional[int] = Field(None, description="结束时间戳(Unix 秒,含)")
|
||
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 导出任务状态
|
||
# ---------------------------------------------------------------------------
|
||
class ExportTaskStatus(BaseModel):
|
||
"""导出任务状态。
|
||
|
||
状态机:pending → running → completed / failed / cancelled。
|
||
completed 时 download_url 字段有效;expires_at 之后下载链接失效。
|
||
"""
|
||
|
||
task_id: str = Field(description="任务 ID(UUID)")
|
||
status: Literal[
|
||
"pending", "running", "completed", "failed", "cancelled"
|
||
] = Field("pending", description="任务状态")
|
||
progress: float = Field(
|
||
0.0, ge=0.0, le=1.0, description="进度 0-1(processed/total)"
|
||
)
|
||
total: int = Field(0, description="待处理消息总数(运行中逐步更新)")
|
||
processed: int = Field(0, description="已处理消息数")
|
||
download_url: Optional[str] = Field(
|
||
None, description="下载链接(status=completed 时有效)"
|
||
)
|
||
expires_at: Optional[int] = Field(
|
||
None, description="下载链接过期时间戳(默认 2 小时后)"
|
||
)
|
||
error_message: Optional[str] = Field(
|
||
None, description="失败原因(status=failed 时有效)"
|
||
)
|