ForcePilot/backend/package/yuxi/channels/contract/dtos/status.py
Kris b88c0ae29e feat(channels): 批量新增多渠道网关限界上下文基础代码与契约
新增完整的 channels 限界上下文模块,包含契约层、领域核心层、应用服务、管道编排、插件体系、基础设施组合根等全层级代码,新增飞书与微信 iLink 渠道插件基础结构,补充各类 DTO、端口协议与领域服务实现。
2026-07-02 03:22:12 +08:00

78 lines
2.1 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.

"""状态 DTO。
定义消息状态事件的枚举与不可变值对象,包括事件类型、消息状态与状态
负载。所有枚举继承 ``str, Enum`` 以支持 JSON 序列化DTO 均为
``dataclass(frozen=True)``,仅依赖标准库,用于渠道侧消息状态事件
(送达 / 已读 / 编辑 / 撤回等)的回传与状态机推进。
"""
from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime
from enum import StrEnum
class EventType(StrEnum):
"""事件类型。
标识渠道侧回传的消息状态事件类型,用于状态事件解析与状态机推进。
继承 ``str, Enum`` 以支持 JSON 序列化与字符串比较。
取值:
MESSAGE: 消息事件。
DELIVERED: 已送达。
READ: 已读。
EDITED: 已编辑。
RECALLED: 已撤回。
UNKNOWN: 未知事件。
AGENT_MENTION: Agent 提及事件(多 Agent 协作,标识 @Agent 提及)。
"""
MESSAGE = "message"
DELIVERED = "delivered"
READ = "read"
EDITED = "edited"
RECALLED = "recalled"
UNKNOWN = "unknown"
AGENT_MENTION = "agent_mention"
class MessageStatus(StrEnum):
"""消息状态。
标识出站消息在渠道侧的状态,用于出站状态机推进与持久化。继承
``str, Enum`` 以支持 JSON 序列化与字符串比较。
取值:
PENDING: 待发送。
SENT: 已发送。
DELIVERED: 已送达。
READ: 已读。
FAILED: 已失败。
"""
PENDING = "pending"
SENT = "sent"
DELIVERED = "delivered"
READ = "read"
FAILED = "failed"
@dataclass(frozen=True)
class StatusPayload:
"""状态负载。
描述渠道侧回传的消息状态事件负载,包括事件类型、关联的渠道消息 ID
与事件时间戳,用于状态事件解析与状态机推进。
字段:
event_type: 事件类型。
ref_channel_msg_id: 关联的渠道消息 ID。
timestamp: 事件时间戳。
"""
event_type: EventType
ref_channel_msg_id: str
timestamp: datetime