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

Function assert_content_allowed

api/messaging.py:70–90  ·  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

68
69
70def assert_content_allowed(*texts: str | None) -> None:
71 """
72 Synchronous acceptable-use check on outbound message content, run before
73 anything is handed to Twilio's client.messages.create / calls.create.
74
75 Screens the caller-supplied text against a maintained slur/profanity
76 wordlist. This is content-neutral enforcement that protects the Twilio
77 account from Messaging Policy violations — the text is never stored or
78 logged, it is only inspected in-memory on the send path.
79
80 Raises HTTPException(400) if the content is rejected.
81 """
82 for text in texts:
83 if text and profanity.contains_profanity(text):
84 raise HTTPException(
85 status_code=400,
86 detail={
87 "message": "Message blocked: the content violates the acceptable use policy. Hate speech, slurs, and abusive language are not permitted.",
88 "error_type": "content_policy",
89 },
90 )
91
92
93async def stash_voice_message(message: str) -> str:

Callers 4

remote_replyFunction · 0.90
send_smsFunction · 0.85
send_whatsappFunction · 0.85
make_voice_callFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected