mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +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:
@@ -20,7 +20,7 @@ from app.api.deps import get_current_active_superuser
|
||||
from app.runtime.extensions.service_registry import ServiceConfigHelper
|
||||
from app.runtime.log import logger
|
||||
from app.adapters.external.wechat_crypt import WXBizMsgCrypt
|
||||
from app.schemas.types import MessageChannel, SystemConfigKey
|
||||
from app.schemas.types import NotificationChannel, SystemConfigKey
|
||||
|
||||
router = ResponseAPIRouter()
|
||||
|
||||
@@ -64,18 +64,18 @@ def _normalize_notification_clear_timestamp(value: Any) -> int:
|
||||
return normalized_value if normalized_value > 0 else 0
|
||||
|
||||
|
||||
def _get_notification_clear_before() -> schemas.NotificationClearBefore:
|
||||
def _get_notification_clear_before() -> schemas.MessageClearBefore:
|
||||
"""
|
||||
读取通知中心清理时间配置。
|
||||
"""
|
||||
value = SystemConfigOper().get(SystemConfigKey.NotificationClearBefore)
|
||||
if isinstance(value, dict):
|
||||
return schemas.NotificationClearBefore(
|
||||
return schemas.MessageClearBefore(
|
||||
all=_normalize_notification_clear_timestamp(value.get("all")),
|
||||
system=_normalize_notification_clear_timestamp(value.get("system")),
|
||||
media=_normalize_notification_clear_timestamp(value.get("media")),
|
||||
)
|
||||
return schemas.NotificationClearBefore(
|
||||
return schemas.MessageClearBefore(
|
||||
all=_normalize_notification_clear_timestamp(value),
|
||||
)
|
||||
|
||||
@@ -166,7 +166,7 @@ async def web_message(
|
||||
images = [images]
|
||||
|
||||
MessageChain().handle_message(
|
||||
channel=MessageChannel.Web,
|
||||
channel=NotificationChannel.Web,
|
||||
source=current_user.name,
|
||||
userid=current_user.name,
|
||||
username=current_user.name,
|
||||
@@ -197,7 +197,7 @@ async def get_web_message(
|
||||
return ret_messages
|
||||
|
||||
|
||||
@router.get("/notification", summary="获取通知消息", response_model=List[schemas.NotificationHistoryItem])
|
||||
@router.get("/notification", summary="获取通知消息", response_model=List[schemas.MessageHistoryItem])
|
||||
async def get_notification_message(
|
||||
_: schemas.TokenPayload = Depends(verify_token),
|
||||
db: AsyncSession = Depends(get_async_db),
|
||||
@@ -215,16 +215,16 @@ async def get_notification_message(
|
||||
system_clear_before=_format_notification_clear_time(clear_before.system),
|
||||
media_clear_before=_format_notification_clear_time(clear_before.media),
|
||||
)
|
||||
return [schemas.NotificationHistoryItem(**message.to_dict()) for message in messages]
|
||||
return [schemas.MessageHistoryItem(**message.to_dict()) for message in messages]
|
||||
|
||||
|
||||
@router.delete(
|
||||
"/notification",
|
||||
summary="清理通知消息",
|
||||
response_model=schemas.Response[schemas.NotificationClearData],
|
||||
response_model=schemas.Response[schemas.MessageClearData],
|
||||
)
|
||||
async def clear_notification_message(
|
||||
scope: schemas.NotificationClearScope = schemas.NotificationClearScope.All,
|
||||
scope: schemas.MessageClearScope = schemas.MessageClearScope.All,
|
||||
_: schemas.TokenPayload = Depends(verify_token),
|
||||
):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user