- 新增登录状态守卫后台任务 - 新增好友申请自动通过规则引擎 - 新增多分辨率UI配置与模板资源 - 新增消息拉取复合游标支持 - 优化发送队列与UI自动化逻辑 - 新增批量发送日志与错误处理 - 优化Docker镜像构建与ptrace初始化 - 新增联系人名称缓存预热
59 lines
2.6 KiB
Python
59 lines
2.6 KiB
Python
"""消息域模型:单条消息 / 消息拉取响应。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 消息接口(GET /api/messages/since)
|
||
# ---------------------------------------------------------------------------
|
||
class Message(BaseModel):
|
||
"""单条微信消息。"""
|
||
|
||
msg_id: str = Field(description="消息 ID")
|
||
talker: str = Field(description="会话对方 wxid(群消息为 chatroom id)")
|
||
sender: str = Field(default="", description="实际发送者 wxid(群消息中为成员 wxid)")
|
||
is_sender: bool = Field(default=False, description="是否为本机发送")
|
||
type: int = Field(description="微信原始消息类型")
|
||
render_type: str = Field(description="渲染类型:text/image/voice/video/file/system")
|
||
content: str = Field(default="", description="消息内容文本")
|
||
create_time: int = Field(description="消息时间戳(Unix 秒)")
|
||
session_type: str = Field(description="会话类型:p2p / group")
|
||
|
||
|
||
class MessagesResponse(BaseModel):
|
||
"""消息拉取响应。"""
|
||
|
||
messages: list[Message] = Field(default_factory=list)
|
||
next_cursor: int = Field(description="下次拉取应使用的 cursor")
|
||
next_cursor_local_id: int = Field(
|
||
default=0, description="下次拉取应使用的 local_id 游标(同秒消息 tie-breaker)"
|
||
)
|
||
has_more: bool = Field(default=False, description="是否可能还有更多消息")
|
||
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 按会话拉取(GET /api/messages/by_session)
|
||
# ---------------------------------------------------------------------------
|
||
class MessagesBySessionResponse(BaseModel):
|
||
"""按会话拉取历史消息响应。"""
|
||
|
||
messages: list[Message] = Field(default_factory=list)
|
||
next_cursor: int = Field(description="下次拉取应使用的 cursor")
|
||
next_cursor_local_id: int = Field(
|
||
default=0, description="下次拉取应使用的 local_id 游标(同秒消息 tie-breaker)"
|
||
)
|
||
has_more: bool = Field(default=False, description="是否可能还有更多消息")
|
||
talker: str = Field(description="本次查询的会话对方 wxid")
|
||
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# 消息搜索(GET /api/messages/search)
|
||
# ---------------------------------------------------------------------------
|
||
class MessageSearchResponse(BaseModel):
|
||
"""消息搜索响应。"""
|
||
|
||
messages: list[Message] = Field(default_factory=list)
|
||
total: int = Field(default=0, description="命中总数(可能大于返回条数)")
|