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)
| 68 | |
| 69 | |
| 70 | def 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 | |
| 93 | async def stash_voice_message(message: str) -> str: |
no outgoing calls
no test coverage detected