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

Function assert_content_allowed

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

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

Callers 6

remote_sendFunction · 0.90
remote_replyFunction · 0.90
remote_telegram_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