MCPcopy Create free account
hub / github.com/Roy3838/Observer / assert_content_allowed

Function assert_content_allowed

api/messaging.py:48–68  ·  view source on GitHub ↗

Synchronous acceptable-use check on outbound message content, run before anything is handed to Twilio's client.messages.create / calls.create. Screens the caller-supplied text against a maintained slur/profanity wordlist. This is content-neutral enforcement that protects the Twilio

(*texts: str | None)

Source from the content-addressed store, hash-verified

46
47
48def assert_content_allowed(*texts: str | None) -> None:
49 """
50 Synchronous acceptable-use check on outbound message content, run before
51 anything is handed to Twilio's client.messages.create / calls.create.
52
53 Screens the caller-supplied text against a maintained slur/profanity
54 wordlist. This is content-neutral enforcement that protects the Twilio
55 account from Messaging Policy violations — the text is never stored or
56 logged, it is only inspected in-memory on the send path.
57
58 Raises HTTPException(400) if the content is rejected.
59 """
60 for text in texts:
61 if text and profanity.contains_profanity(text):
62 raise HTTPException(
63 status_code=400,
64 detail={
65 "message": "Message blocked: the content violates the acceptable use policy. Hate speech, slurs, and abusive language are not permitted.",
66 "error_type": "content_policy",
67 },
68 )
69
70
71async def stash_voice_message(message: str) -> str:

Callers 3

send_smsFunction · 0.85
send_whatsappFunction · 0.85
make_voice_callFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected