fix(cron): preserve Telegram topic targets
This commit is contained in:
+3
-1
@@ -198,7 +198,9 @@ def _resolve_single_delivery_target(job: dict, deliver_value: str) -> Optional[d
|
|||||||
if resolved:
|
if resolved:
|
||||||
parsed_chat_id, parsed_thread_id, resolved_is_explicit = _parse_target_ref(platform_key, resolved)
|
parsed_chat_id, parsed_thread_id, resolved_is_explicit = _parse_target_ref(platform_key, resolved)
|
||||||
if resolved_is_explicit:
|
if resolved_is_explicit:
|
||||||
chat_id, thread_id = parsed_chat_id, parsed_thread_id
|
chat_id = parsed_chat_id
|
||||||
|
if parsed_thread_id is not None:
|
||||||
|
thread_id = parsed_thread_id
|
||||||
else:
|
else:
|
||||||
chat_id = resolved
|
chat_id = resolved
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@@ -129,6 +129,22 @@ class TestResolveDeliveryTarget:
|
|||||||
"thread_id": "17",
|
"thread_id": "17",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def test_explicit_telegram_topic_thread_survives_bare_directory_match(self):
|
||||||
|
"""Exact channel-directory matches must not erase an explicit topic id."""
|
||||||
|
job = {
|
||||||
|
"deliver": "telegram:-1003724596514:17",
|
||||||
|
}
|
||||||
|
with patch(
|
||||||
|
"gateway.channel_directory.resolve_channel_name",
|
||||||
|
return_value="-1003724596514",
|
||||||
|
):
|
||||||
|
result = _resolve_delivery_target(job)
|
||||||
|
assert result == {
|
||||||
|
"platform": "telegram",
|
||||||
|
"chat_id": "-1003724596514",
|
||||||
|
"thread_id": "17",
|
||||||
|
}
|
||||||
|
|
||||||
def test_explicit_telegram_chat_id_without_thread_id(self):
|
def test_explicit_telegram_chat_id_without_thread_id(self):
|
||||||
"""deliver: 'telegram:chat_id' sets thread_id to None."""
|
"""deliver: 'telegram:chat_id' sets thread_id to None."""
|
||||||
job = {
|
job = {
|
||||||
|
|||||||
Reference in New Issue
Block a user