mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
支持微信/WhatsApp 回送附件直发并补齐链路测试。
保持入站到 agent 流程不变,在回送阶段支持 media_path/media_url 与 base64 附件直发,同时让通道回包沿用会话中助手附件记录以对齐 chat 历史逻辑。 Made-with: Cursor
This commit is contained in:
parent
25180921e7
commit
1d46356d9e
8 changed files with 255 additions and 7 deletions
|
|
@ -15,7 +15,23 @@ def test_inbound_whatsapp_accepts_basic_payload_and_returns_replies() -> None:
|
|||
assert str(payload.get("account_id") or "") == "wa-default"
|
||||
assert str(payload.get("user_id") or "") == "111@s.whatsapp.net"
|
||||
assert str(payload.get("chat_id") or "") == "111@s.whatsapp.net"
|
||||
return {"ok": True, "replies": [{"chat_id": payload.get("chat_id"), "text": "ok"}]}
|
||||
return {
|
||||
"ok": True,
|
||||
"replies": [
|
||||
{
|
||||
"chat_id": payload.get("chat_id"),
|
||||
"text": "ok",
|
||||
"attachments": [
|
||||
{
|
||||
"type": "binary_ref",
|
||||
"name": "hello.txt",
|
||||
"mime_type": "text/plain",
|
||||
"data_base64": "aGVsbG8=",
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
try:
|
||||
fastapi_app.process_inbound_payload_usecase = _fake_usecase # type: ignore[assignment]
|
||||
|
|
@ -35,6 +51,9 @@ def test_inbound_whatsapp_accepts_basic_payload_and_returns_replies() -> None:
|
|||
replies = data.get("replies") if isinstance(data.get("replies"), list) else []
|
||||
assert replies and isinstance(replies[0], dict)
|
||||
assert str(replies[0].get("text") or "") == "ok"
|
||||
atts = replies[0].get("attachments") if isinstance(replies[0].get("attachments"), list) else []
|
||||
assert len(atts) == 1
|
||||
assert str(atts[0].get("name") or "") == "hello.txt"
|
||||
finally:
|
||||
fastapi_app.process_inbound_payload_usecase = old_usecase # type: ignore[assignment]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue