mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +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:
@@ -679,6 +679,62 @@ PACKAGE_EXPORTS: Dict[str, Dict[str, SymbolAlias]] = {
|
||||
|
||||
# 物理模块仍存在、仅部分公开符号迁走时,由导入器在标准 Loader 执行后叠加惰性符号路由。
|
||||
# canonical 源码不反向依赖兼容层,目标符号也只在旧调用方真正取用时加载。
|
||||
|
||||
# message/notification 命名统一后的旧符号映射:
|
||||
# 通知渠道能力归 notification(NotificationChannel),消息收发归 message(Message/MessageType)。
|
||||
# 旧名在 app.schemas、app.schemas.message 两个入口都曾公开,共用同一份映射。
|
||||
_MESSAGE_NOTIFICATION_SYMBOL_ALIASES: Dict[str, SymbolAlias] = {
|
||||
"MessageChannel": SymbolAlias(
|
||||
target_module="app.schemas.types",
|
||||
target_name="NotificationChannel",
|
||||
replacement="app.schemas.types.NotificationChannel",
|
||||
),
|
||||
"NotificationType": SymbolAlias(
|
||||
target_module="app.schemas.types",
|
||||
target_name="MessageType",
|
||||
replacement="app.schemas.types.MessageType",
|
||||
),
|
||||
"Notification": SymbolAlias(
|
||||
target_module="app.schemas.message",
|
||||
target_name="Message",
|
||||
replacement="app.schemas.message.Message",
|
||||
),
|
||||
"CommingMessage": SymbolAlias(
|
||||
target_module="app.schemas.message",
|
||||
target_name="IncomingMessage",
|
||||
replacement="app.schemas.message.IncomingMessage",
|
||||
),
|
||||
"NotificationHistoryItem": SymbolAlias(
|
||||
target_module="app.schemas.message",
|
||||
target_name="MessageHistoryItem",
|
||||
replacement="app.schemas.message.MessageHistoryItem",
|
||||
),
|
||||
**{
|
||||
old: SymbolAlias(
|
||||
target_module="app.schemas.message",
|
||||
target_name=new,
|
||||
replacement=f"app.schemas.message.{new}",
|
||||
)
|
||||
for old, new in (
|
||||
("NotificationClearScope", "MessageClearScope"),
|
||||
("NotificationClearBefore", "MessageClearBefore"),
|
||||
("NotificationClearData", "MessageClearData"),
|
||||
)
|
||||
},
|
||||
**{
|
||||
name: SymbolAlias(
|
||||
target_module="app.schemas.notification",
|
||||
target_name=name,
|
||||
replacement=f"app.schemas.notification.{name}",
|
||||
)
|
||||
for name in (
|
||||
"ChannelCapability",
|
||||
"ChannelCapabilities",
|
||||
"ChannelCapabilityManager",
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
SYMBOL_ALIASES: Dict[str, Dict[str, SymbolAlias]] = {
|
||||
"app.chain.message": {
|
||||
"MediaInteractionChain": SymbolAlias(
|
||||
@@ -704,12 +760,15 @@ SYMBOL_ALIASES: Dict[str, Dict[str, SymbolAlias]] = {
|
||||
)
|
||||
},
|
||||
"app.schemas": {
|
||||
name: SymbolAlias(
|
||||
target_module="app.sdk._legacy.transfer",
|
||||
target_name=name,
|
||||
replacement=f"app.application.transfer.{name}",
|
||||
)
|
||||
for name in ("TransferTask", "TransferQueue")
|
||||
**{
|
||||
name: SymbolAlias(
|
||||
target_module="app.sdk._legacy.transfer",
|
||||
target_name=name,
|
||||
replacement=f"app.application.transfer.{name}",
|
||||
)
|
||||
for name in ("TransferTask", "TransferQueue")
|
||||
},
|
||||
**_MESSAGE_NOTIFICATION_SYMBOL_ALIASES,
|
||||
},
|
||||
"app.schemas.transfer": {
|
||||
name: SymbolAlias(
|
||||
@@ -719,4 +778,18 @@ SYMBOL_ALIASES: Dict[str, Dict[str, SymbolAlias]] = {
|
||||
)
|
||||
for name in ("TransferTask", "TransferQueue")
|
||||
},
|
||||
# message/notification 命名统一:通知渠道能力归 notification,消息收发归 message
|
||||
"app.schemas.types": {
|
||||
"MessageChannel": SymbolAlias(
|
||||
target_module="app.schemas.types",
|
||||
target_name="NotificationChannel",
|
||||
replacement="app.schemas.types.NotificationChannel",
|
||||
),
|
||||
"NotificationType": SymbolAlias(
|
||||
target_module="app.schemas.types",
|
||||
target_name="MessageType",
|
||||
replacement="app.schemas.types.MessageType",
|
||||
),
|
||||
},
|
||||
"app.schemas.message": _MESSAGE_NOTIFICATION_SYMBOL_ALIASES,
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ from app.runtime.config import settings
|
||||
from app.runtime.events import EventHandlerBinding, eventmanager
|
||||
from app.foundation.reflection import ModuleHelper
|
||||
from app.runtime.log import logger
|
||||
from app.schemas.types import EventType, ModuleType, DownloaderType, MediaServerType, MessageChannel, StorageSchema, \
|
||||
from app.schemas.types import EventType, ModuleType, DownloaderType, MediaServerType, NotificationChannel, StorageSchema, \
|
||||
OtherModulesType, MediaRecognizeType
|
||||
from app.foundation.reflection import ObjectUtils
|
||||
from app.foundation.singleton import Singleton
|
||||
@@ -20,7 +20,7 @@ class ModuleManager(metaclass=Singleton):
|
||||
SubType = Union[
|
||||
DownloaderType,
|
||||
MediaServerType,
|
||||
MessageChannel,
|
||||
NotificationChannel,
|
||||
StorageSchema,
|
||||
OtherModulesType,
|
||||
MediaRecognizeType,
|
||||
|
||||
@@ -6,7 +6,7 @@ from app.runtime.extensions.module_manager import ModuleManager
|
||||
from app.db.oper.systemconfig import SystemConfigOper
|
||||
from app.runtime.log import logger
|
||||
from app.schemas import DownloaderConf, MediaServerConf, NotificationConf, NotificationSwitchConf, ServiceInfo
|
||||
from app.schemas.types import NotificationType, SystemConfigKey, ModuleType
|
||||
from app.schemas.types import MessageType, SystemConfigKey, ModuleType
|
||||
|
||||
TConf = TypeVar("TConf")
|
||||
|
||||
@@ -70,7 +70,7 @@ class ServiceConfigHelper:
|
||||
return ServiceConfigHelper.get_configs(SystemConfigKey.NotificationSwitchs, NotificationSwitchConf)
|
||||
|
||||
@staticmethod
|
||||
def get_notification_switch(mtype: NotificationType) -> Optional[str]:
|
||||
def get_notification_switch(mtype: MessageType) -> Optional[str]:
|
||||
"""
|
||||
获取指定类型的消息通知场景的开关
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user