mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
refactor(schemas): 统一 message/notification 命名边界,旧名收敛至兼容映射表
- notification 域:渠道能力(MessageChannel→NotificationChannel、ChannelCapability* 迁入 notification.py) - message 域:消息收发(Notification→Message、NotificationType→MessageType、CommingMessage→IncomingMessage、NotificationHistoryItem→MessageHistoryItem、NotificationClear*→MessageClear*) - Agent 工具契约:send_notification_message→send_message、notification_callback→message_callback - 源码不保留旧名物理别名,旧导入经 app/runtime/compat/manifest.py SYMBOL_ALIASES 惰性解析 - API 路径与持久化键冻结不变,前端零改动 - 新增兼容守护测试与 docs/rules/07 命名边界规范
This commit is contained in:
@@ -5,7 +5,7 @@ from queue import Queue
|
||||
from threading import Lock
|
||||
from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union
|
||||
|
||||
from app.schemas.types import MessageChannel
|
||||
from app.schemas.types import NotificationChannel
|
||||
|
||||
# Agent 选择按钮回调前缀(新旧两种格式都必须继续兼容)
|
||||
AGENT_CHOICE_PREFIX = "agent_interaction:choice:"
|
||||
@@ -180,7 +180,7 @@ _CHANNEL_ADMIN_RESOLVERS: dict[str, _ChannelAdminResolver] = {}
|
||||
|
||||
|
||||
def register_channel_admin_resolver(
|
||||
channel: Union[MessageChannel, str],
|
||||
channel: Union[NotificationChannel, str],
|
||||
resolver: _ChannelAdminResolver,
|
||||
) -> None:
|
||||
"""
|
||||
@@ -189,7 +189,7 @@ def register_channel_admin_resolver(
|
||||
:param channel: 消息渠道
|
||||
:param resolver: 由渠道配置解析全部管理员主体 ID 的函数
|
||||
"""
|
||||
channel_value = channel.value if isinstance(channel, MessageChannel) else str(channel)
|
||||
channel_value = channel.value if isinstance(channel, NotificationChannel) else str(channel)
|
||||
_CHANNEL_ADMIN_RESOLVERS[channel_value] = resolver
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ def resolve_config_principal_ids(
|
||||
|
||||
|
||||
def matches_channel_admin(
|
||||
channel: Union[MessageChannel, str],
|
||||
channel: Union[NotificationChannel, str],
|
||||
config: Optional[dict],
|
||||
*principal_ids: Optional[Union[str, int]],
|
||||
) -> bool:
|
||||
@@ -227,7 +227,7 @@ def matches_channel_admin(
|
||||
:param principal_ids: 消息渠道提供的稳定用户主体 ID
|
||||
:return: 任一用户主体 ID 命中渠道注册的管理员集合时返回 True
|
||||
"""
|
||||
channel_value = channel.value if isinstance(channel, MessageChannel) else str(channel)
|
||||
channel_value = channel.value if isinstance(channel, NotificationChannel) else str(channel)
|
||||
resolver = _CHANNEL_ADMIN_RESOLVERS.get(channel_value)
|
||||
if not resolver:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user