feat(webhook): support platform:chat_id format in deliver config - #49591
feat(webhook): support platform:chat_id format in deliver config#49591kas-cor wants to merge 2 commits into
Conversation
Allow webhook subscriptions to use 'telegram:-1003774178835' format in the deliver field to target a specific channel or chat. - Parse platform:chat_id format in send() method - Pass target_chat_id to _deliver_cross_platform - Priority: target_chat_id > deliver_extra.chat_id > home channel
|
Thanks for addressing a real webhook-delivery gap: current main still treats Problems
Suggested changes
Automated hermes-sweeper review. |
…ests Address sweeper review (teknium1): - Extract _parse_deliver_target() shared by send() and _direct_deliver() - _direct_deliver() now parses platform:chat_id before Platform() lookup - Add tests for deliver_only + agent-mode inline chat IDs - Add tests for precedence: target_chat_id > deliver_extra > home channel - Add unit tests for _parse_deliver_target()
Fixes applied — addressing sweeper reviewThanks @teknium1 for the review! Pushed a fix ( 1. Normalize delivery target in a shared pathExtracted @staticmethod
def _parse_deliver_target(deliver_type: str) -> tuple[str, Optional[str]]:
if ":" not in deliver_type:
return deliver_type, None
parts = deliver_type.split(":", 2)
platform_name = parts[0].lower()
chat_id = parts[1] if len(parts) > 1 and parts[1] else None
return platform_name, chat_idBoth code paths now call it:
2. Regression tests added
All 27 tests pass: |
|
Hi @teknium1 — the review feedback was addressed in |
Summary
Allow webhook subscriptions to use
telegram:-1003774178835format in thedeliverfield to target a specific channel or chat, not just the home channel.Problem
When configuring a webhook subscription with
--deliver "telegram:-1003774178835", the webhook adapter treated the entire string as a platform name and failed withUnknown deliver type: telegram:-1003774178835. This forced users to either:deliver_extra.chat_id(which also didn't work for agent-mode webhooks)Changes
gateway/platforms/webhook.pysend()method — Parseplatform:chat_idformat before platform lookup::to extract platform name and optional chat_idtarget_chat_idto_deliver_cross_platform_deliver_cross_platform()method — Accept optionaltarget_chat_idparameter:target_chat_id>deliver_extra.chat_id> home channelNoneUsage
Testing
deliver: telegramcontinue to use home channel (no change)deliver: telegram:-1003774178835deliver to the specified chatdeliver_extra.chat_idstill works as fallback