fix(send-message): treat ntfy topic targets as explicit
This commit is contained in:
@@ -143,7 +143,7 @@ SEND_MESSAGE_SCHEMA = {
|
||||
},
|
||||
"target": {
|
||||
"type": "string",
|
||||
"description": "Delivery target. Format: 'platform' (uses home channel), 'platform:#channel-name', 'platform:chat_id', or 'platform:chat_id:thread_id' for Telegram topics and Discord threads. Examples: 'telegram', 'telegram:-1001234567890:17585', 'discord:999888777:555444333', 'discord:#bot-home', 'slack:#engineering', 'signal:+155****4567', 'matrix:!roomid:server.org', 'matrix:@user:server.org', 'yuanbao:direct:<account_id>' (DM), 'yuanbao:group:<group_code>' (group chat)"
|
||||
"description": "Delivery target. Format: 'platform' (uses home channel), 'platform:#channel-name', 'platform:chat_id', or 'platform:chat_id:thread_id' for Telegram topics and Discord threads. Examples: 'telegram', 'telegram:-1001234567890:17585', 'discord:999888777:555444333', 'discord:#bot-home', 'slack:#engineering', 'signal:+155****4567', 'matrix:!roomid:server.org', 'matrix:@user:server.org', 'ntfy:alerts-channel' (explicit ntfy topic), 'yuanbao:direct:<account_id>' (DM), 'yuanbao:group:<group_code>' (group chat)"
|
||||
},
|
||||
"message": {
|
||||
"type": "string",
|
||||
@@ -395,6 +395,10 @@ def _parse_target_ref(platform_name: str, target_ref: str):
|
||||
if target_ref.strip().isdigit():
|
||||
return f"group:{target_ref.strip()}", None, True
|
||||
return None, None, False
|
||||
if platform_name == "ntfy":
|
||||
topic = target_ref.strip()
|
||||
if topic:
|
||||
return topic, None, True
|
||||
if platform_name == "email":
|
||||
match = _EMAIL_TARGET_RE.fullmatch(target_ref)
|
||||
if match:
|
||||
@@ -502,6 +506,7 @@ async def _send_via_adapter(
|
||||
the runner weakref is ``None``).
|
||||
3. A descriptive error explaining both options.
|
||||
"""
|
||||
platform_name = platform.value if hasattr(platform, "value") else str(platform)
|
||||
runner = None
|
||||
try:
|
||||
from gateway.run import _gateway_runner_ref
|
||||
@@ -516,7 +521,13 @@ async def _send_via_adapter(
|
||||
adapter = None
|
||||
if adapter is not None:
|
||||
try:
|
||||
metadata = {"thread_id": thread_id} if thread_id else None
|
||||
metadata = {}
|
||||
if thread_id:
|
||||
metadata["thread_id"] = thread_id
|
||||
if platform_name == "ntfy" and chat_id:
|
||||
metadata["publish_topic"] = chat_id
|
||||
if not metadata:
|
||||
metadata = None
|
||||
result = await adapter.send(chat_id=chat_id, content=chunk, metadata=metadata)
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
@@ -526,7 +537,6 @@ async def _send_via_adapter(
|
||||
return {"success": True, "message_id": result.message_id}
|
||||
return {"error": f"Adapter send failed: {result.error}"}
|
||||
|
||||
platform_name = platform.value if hasattr(platform, "value") else str(platform)
|
||||
entry = None
|
||||
try:
|
||||
from gateway.platform_registry import platform_registry
|
||||
|
||||
Reference in New Issue
Block a user