The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cron): forward the voice flag when cron delivery calls send_voice
liuhao1024da1453688a8d
diff --git a/cron/scheduler_delivery.py b/cron/scheduler_delivery.pyindex 335a3ca5704..80f5d029f18 100644--- a/cron/scheduler_delivery.py+++ b/cron/scheduler_delivery.py@@ -949,8 +949,12 @@ def _send_media_via_adapter(method, path_kw = "send_image_file", "image_path"else:method, path_kw = "send_document", "file_path"+ # The voice sender decides bubble vs music-file from ``is_voice`` (Telegram+ # transcodes non-Opus only when it is set), matching the gateway dispatch+ # in BasePlatformAdapter._send_one.+ extra = {"is_voice": _is_voice} if method == "send_voice" else {}coro = getattr(adapter, method)(- chat_id=chat_id, metadata=metadata, **{path_kw: media_path})+ chat_id=chat_id, metadata=metadata, **{path_kw: media_path}, **extra)future = safe_schedule_threadsafe(coro, loop)if future is None:_note_target_error(diff --git a/tests/cron/test_scheduler.py b/tests/cron/test_scheduler.pyindex d8efa2e854c..0cf46279537 100644--- a/tests/cron/test_scheduler.py+++ b/tests/cron/test_scheduler.py@@ -1713,6 +1713,39 @@ class TestSendMediaViaAdapter:adapter.send_voice.assert_called_once()adapter.send_image_file.assert_called_once()+ def test_voice_flag_forwarded_to_send_voice(self, tmp_path, monkeypatch):+ """Issue #132120: a ``[[audio_as_voice]]`` media file must reach the adapter —+ Telegram decides voice-bubble vs sendAudio from the ``is_voice`` kwarg, so a+ cron .mp3 without the flag arrives as a music file, not a bubble."""+ adapter = MagicMock()+ adapter.platform = "telegram"+ adapter.send_voice = AsyncMock()+ voice_path = self._safe_media_path(tmp_path, monkeypatch, "voice.mp3")+ self._run_with_loop(adapter, "123", [(str(voice_path), True)], None, {"id": "j4"})+ adapter.send_voice.assert_called_once()+ assert adapter.send_voice.call_args.kwargs["is_voice"] is True++ def test_audio_attachment_without_voice_flag_forwards_false(self, tmp_path, monkeypatch):+ """A plain audio-ext attachment on Telegram also routes to send_voice (the sendAudio+ lane); it must forward ``is_voice=False`` so it is never turned into a bubble."""+ adapter = MagicMock()+ adapter.platform = "telegram"+ adapter.send_voice = AsyncMock()+ audio_path = self._safe_media_path(tmp_path, monkeypatch, "clip.mp3")+ self._run_with_loop(adapter, "123", [(str(audio_path), False)], None, {"id": "j5"})+ adapter.send_voice.assert_called_once()+ assert adapter.send_voice.call_args.kwargs["is_voice"] is False++ def test_non_voice_methods_do_not_receive_is_voice(self, tmp_path, monkeypatch):+ """Only the voice sender takes the flag; image sends must not see it."""+ adapter = MagicMock()+ adapter.platform = "telegram"+ adapter.send_image_file = AsyncMock()+ photo_path = self._safe_media_path(tmp_path, monkeypatch, "photo.jpg")+ self._run_with_loop(adapter, "123", [(str(photo_path), False)], None, {"id": "j6"})+ adapter.send_image_file.assert_called_once()+ assert "is_voice" not in adapter.send_image_file.call_args.kwargs+class TestParallelTick:"""Verify that tick() runs due jobs concurrently and isolates ContextVars."""