WechatOnCloud/bridge/woc_bridge/models/batch_send.py
Kris 2348a04163 feat: 完成微信4.0模板UI重构与批量群发、导出功能落地
本次提交包含多项核心更新:
1. 新增微信4.0浅色主题UI模板资源与说明文档,补充了联系人图标、新的朋友入口等四个UI元素的图像匹配模板
2. 重构UI驱动层,将原2375行的单文件拆分为5个职责清晰的子驱动类,提升代码可维护性
3. 新增批量群发消息与聊天记录导出的完整数据模型、路由与后台协程,支持幂等校验与风控配置
4. 为所有业务接口新增post_verify校验逻辑,补充了verified字段返回操作结果
5. 优化媒体文件解密逻辑,修复了导出功能中的数据库错误处理与分辨率硬编码问题
6. 更新版本配置,将媒体发送功能标记为已落地,调整了能力列表与配置项
2026-07-16 16:53:42 +08:00

68 lines
2.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""群发消息相关数据模型。"""
from __future__ import annotations
from typing import Optional, Literal
from pydantic import BaseModel, Field
class BatchSendRequest(BaseModel):
"""群发请求。
三层幂等:
- 批级client_request_idNone 时自动生成 batch_id
- 单条:内部按 f"{batch_id}:{to_wxid}" 作为 client_request_id 传给 orchestrator
- orchestrator复用 IdemCacheTTL=300s
"""
targets: list[str] = Field(
...,
min_length=1,
max_length=200,
description="目标 wxid 列表(去重后 ≤ 200",
)
content: str = Field(
...,
min_length=1,
max_length=2000,
description="消息内容(支持 {nickname} 占位符,发送前按目标联系人替换)",
)
client_request_id: Optional[str] = Field(
None,
description="可选:批级幂等 IDNone 时自动生成 batch_id",
)
abort_on_consecutive_fail: int = Field(
5,
ge=1,
le=20,
description="连续失败 N 次中止整批(剩余标记 skipped",
)
class BatchItemResult(BaseModel):
"""单条群发结果。"""
to_wxid: str
# unknown: 发送被 cancel 中断实际发送状态未知send_queue worker 可能已发出)
status: Literal["success", "failed", "skipped", "pending", "unknown"]
error_code: Optional[str] = None
error_message: Optional[str] = None
verified: Optional[bool] = None
class BatchSendStatus(BaseModel):
"""群发任务状态。"""
batch_id: str
status: Literal["pending", "running", "completed", "failed", "cancelled"] = "pending"
total: int = 0
processed: int = 0
success: int = 0
failed: int = 0
skipped: int = 0
progress: float = Field(0.0, ge=0.0, le=1.0)
estimated_remaining_sec: Optional[int] = None
abort_reason: Optional[str] = None
items: Optional[list[BatchItemResult]] = None # 详细结果(可选,列表大时省略)