mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-09 01:16:50 +08:00
fix(notification): skip unsupported DingTalk command registration
This commit is contained in:
@@ -44,6 +44,12 @@ class DingTalkModule(_MessageChannelModuleBase[DingTalk]):
|
||||
"""钉钉启用状态由通知渠道配置统一管理。"""
|
||||
return None
|
||||
|
||||
def _commands_enabled(self, config: Optional[dict]) -> bool:
|
||||
"""
|
||||
钉钉自定义机器人没有命令注册或删除 API,跳过基类命令处理。
|
||||
"""
|
||||
return False
|
||||
|
||||
def post_message(self, message: Message, **kwargs) -> None:
|
||||
"""向所有匹配消息范围的钉钉配置发送普通通知。"""
|
||||
for conf in self.get_configs().values():
|
||||
|
||||
@@ -111,6 +111,19 @@ def test_module_routes_matching_notifications_to_dingtalk_client(monkeypatch) ->
|
||||
client.send_msg.assert_called_once()
|
||||
|
||||
|
||||
def test_module_skips_unsupported_command_registration(monkeypatch) -> None:
|
||||
"""钉钉机器人不支持命令 API 时应跳过基类命令注册流程。"""
|
||||
module = DingTalkModule()
|
||||
config = SimpleNamespace(name="家庭群", config={})
|
||||
get_instance = Mock()
|
||||
monkeypatch.setattr(module, "get_configs", lambda: {config.name: config})
|
||||
monkeypatch.setattr(module, "get_instance", get_instance)
|
||||
|
||||
module.register_commands({"/version": {"description": "当前版本"}})
|
||||
|
||||
get_instance.assert_not_called()
|
||||
|
||||
|
||||
def test_dingtalk_channel_declares_markdown_image_and_link_capabilities() -> None:
|
||||
"""能力表应允许通用消息层保留钉钉支持的富文本字段。"""
|
||||
for capability in (
|
||||
|
||||
Reference in New Issue
Block a user