Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix: preserve WhatsApp forwarded metadata
chengyongrue1ff0f37d9b6
diff --git a/nanobot/channels/whatsapp.py b/nanobot/channels/whatsapp.pyindex 268b62f31..a989df03c 100644--- a/nanobot/channels/whatsapp.py+++ b/nanobot/channels/whatsapp.py@@ -290,6 +290,7 @@ class WhatsAppChannel(BaseChannel):"message_id": message_id,"timestamp": data.get("timestamp"),"is_group": data.get("isGroup", False),+ "is_forwarded": bool(data.get("isForwarded", False)),"participant": participant or None,"is_reply_to_bot": data.get("isReplyToBot", False),},diff --git a/tests/channels/test_whatsapp_channel.py b/tests/channels/test_whatsapp_channel.pyindex cb5fc639b..04d498dee 100644--- a/tests/channels/test_whatsapp_channel.py+++ b/tests/channels/test_whatsapp_channel.py@@ -291,6 +291,30 @@ async def test_voice_message_transcription_uses_media_path():assert kwargs["content"].startswith("Hello world")+async def test_forwarded_voice_message_preserves_metadata_after_transcription():+ ch = WhatsAppChannel({"enabled": True, "allowFrom": ["*"]}, MagicMock())+ ch._handle_message = AsyncMock()+ ch.transcribe_audio = AsyncMock(return_value="Forwarded audio text")++ await ch._handle_bridge_message(+ json.dumps({+ "type": "message",+ "id": "v-forwarded",+ "sender": "[email protected]",+ "pn": "",+ "content": "[Voice Message]",+ "timestamp": 1,+ "media": ["/tmp/voice.ogg"],+ "isForwarded": True,+ })+ )++ kwargs = ch._handle_message.await_args.kwargs+ assert kwargs["content"] == "Forwarded audio text"+ assert kwargs["metadata"]["is_forwarded"] is True++@pytest.mark.asyncioasync def test_unauthorized_voice_message_does_not_transcribe() -> None:ch = WhatsAppChannel({"enabled": True, "allowFrom": ["allowed"]}, MagicMock())