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)
| 46 | |
| 47 | |
| 48 | def 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 | |
| 71 | async def stash_voice_message(message: str) -> str: |
no outgoing calls
no test coverage detected