mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-08 23:33:16 +08:00
Notify WhatsApp requesters on access decisions and ship EN ops help.
After admin YES/NO, DM the requester a field guide; WA help/bind no longer returns the Chinese productivity todo menu. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
f31ebeb30e
commit
94a1b5b26c
5 changed files with 179 additions and 5 deletions
|
|
@ -272,6 +272,17 @@ def test_handle_whatsapp_access_admin_yes_with_stanza_mapping(monkeypatch) -> No
|
|||
replies = out.get("replies") if isinstance(out.get("replies"), list) else []
|
||||
md = replies[0].get("metadata") if replies and isinstance(replies[0], dict) else {}
|
||||
assert md.get("quote_stanza_id") == "admin_reply_1"
|
||||
decision = [
|
||||
o
|
||||
for o in store.outbound
|
||||
if "whatsapp_access_decision" in str(o.get("source") or "")
|
||||
]
|
||||
assert len(decision) == 1
|
||||
assert "8615601877957" in str(decision[0].get("chat_id") or "")
|
||||
assert "Access approved" in str(decision[0].get("text") or "")
|
||||
assert "@mention" in str(decision[0].get("text") or "").lower() or "fiber" in str(
|
||||
decision[0].get("text") or ""
|
||||
).lower()
|
||||
|
||||
|
||||
def test_handle_whatsapp_access_admin_yes_with_quoted_text_fallback(monkeypatch) -> None:
|
||||
|
|
@ -305,6 +316,13 @@ def test_handle_whatsapp_access_admin_yes_with_quoted_text_fallback(monkeypatch)
|
|||
assert out is not None
|
||||
assert store.pending[0]["status"] == "denied"
|
||||
assert store.contacts.get("8615601877957", {}).get("list_type") == "blacklist"
|
||||
decision = [
|
||||
o
|
||||
for o in store.outbound
|
||||
if "whatsapp_access_decision" in str(o.get("source") or "")
|
||||
]
|
||||
assert len(decision) == 1
|
||||
assert "not approved" in str(decision[0].get("text") or "").lower()
|
||||
|
||||
|
||||
def test_handle_whatsapp_access_denied_enqueues_notify_with_pending_source(monkeypatch) -> None:
|
||||
|
|
|
|||
39
tests/test_whatsapp_ops_onboarding.py
Normal file
39
tests/test_whatsapp_ops_onboarding.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from runtime.application.gateway.inbound_service import _handle_productivity_commands, _menu_text
|
||||
from runtime.extensions.whatsapp.access_control import (
|
||||
access_granted_guide_text,
|
||||
whatsapp_ops_help_text,
|
||||
)
|
||||
|
||||
|
||||
def test_whatsapp_ops_help_is_english_field_guide() -> None:
|
||||
text = whatsapp_ops_help_text(lang="en")
|
||||
assert "fiber" in text.lower() or "alarm" in text.lower()
|
||||
assert "@mention" in text.lower() or "mention" in text.lower()
|
||||
assert "记待办" not in text
|
||||
|
||||
|
||||
def test_access_granted_guide_includes_ops_help() -> None:
|
||||
text = access_granted_guide_text(lang="en")
|
||||
assert "Access approved" in text
|
||||
assert "YES" in text or "continue" in text.lower()
|
||||
|
||||
|
||||
def test_menu_text_whatsapp_not_productivity_chinese() -> None:
|
||||
text = _menu_text(channel="whatsapp")
|
||||
assert "记待办" not in text
|
||||
assert "fiber" in text.lower() or "alarm" in text.lower()
|
||||
assert "记待办" in _menu_text(channel="weixin")
|
||||
|
||||
|
||||
def test_productivity_help_on_whatsapp_returns_ops_guide() -> None:
|
||||
out = _handle_productivity_commands(
|
||||
text="help",
|
||||
tenant_id="t1",
|
||||
user_id="u1",
|
||||
channel="whatsapp",
|
||||
)
|
||||
assert out is not None
|
||||
assert "记待办" not in out
|
||||
assert "fiber" in out.lower() or "offline" in out.lower() or "alarm" in out.lower()
|
||||
Loading…
Add table
Add a link
Reference in a new issue